相关疑难解决方法(0)

猫鼬:嵌套的ref模型人口

如何填充嵌套引用的模型?

例如:

// 'Collection' model
var CollectionSchema = new Schema({
  collection_name: String,
  _groups: [{ type: Schema.Types.ObjectId, ref: 'Group' }],
});

// 'Group' model
var GroupSchema = new Schema({
  group_name: String,
  _item: { type: Schema.Types.ObjectId, ref: 'Item' }  // To be populated
  _meta: [ { type: Schema.Types.ObjectId, ref: 'Meta' } // To be populated
});

// 'Item' model
var ItemSchema = new Schema({
  item_name: String,
  item_description: String
});

// 'Meta' model
var MetaSchema = new Schema({
  meta_name: String,
  meta_value: String
}); …
Run Code Online (Sandbox Code Playgroud)

mongoose node.js data-structures

0
推荐指数
1
解决办法
3446
查看次数

标签 统计

data-structures ×1

mongoose ×1

node.js ×1