MONGOOSE - ObjectId 引用集合 VS 集合数组
MONGOOSE - ObjectId reference to collection VS Array of collection
好吧,我是 mongodb/mongoose 的新手,所以其中一些概念在我脑海中仍然有些混乱。任何人都可以向我解释以下内容之间的区别:
var PersonSchema = new Schema({
name : String,
groups: [{ type: Schema.ObjectId, ref: 'Group' }]
});
和
var GroupsSchema = new Schema({
name : String
});
var PersonSchema = new Schema({
name : String,
groups : [GroupsSchema ]
});
谢谢!
好吧,我是 mongodb/mongoose 的新手,所以其中一些概念在我脑海中仍然有些混乱。任何人都可以向我解释以下内容之间的区别:
var PersonSchema = new Schema({
name : String,
groups: [{ type: Schema.ObjectId, ref: 'Group' }]
});
和
var GroupsSchema = new Schema({
name : String
});
var PersonSchema = new Schema({
name : String,
groups : [GroupsSchema ]
});
谢谢!