请我如何在 mongoDB 中添加关系,因为我刚开始使用它。例如Comment id 是一个外键:
@Document
class Comment {
@Id
private String id;
private String text;
private String author;
// constructors, getters and setters are ommited
}
@Document
class Article {
@Id
private String id;
@DBRef(lazy = true)
@CascadeSave
private List<Comment> comments;
private String title;
private String text;
// constructors, getters and setters are ommited
}