Mongoose“ref”文档,找不到

时间:2016-06-30 18:04:58

标签: node.js mongodb mongoose

在定义Mongoose架构时,我花了半个小时的时间尝试查找ref属性的文档。我找不到了!

branch: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Branch' // <--- Where is the documentation for this property
}

有人可以通过我的英雄和链接到哪里。

我尝试了以下内容:http://mongoosejs.com/index.html并选择“阅读文档”,nada。 :(

1 个答案:

答案 0 :(得分:0)

This是我在文档中唯一可以找到对[25,24,23,22,21]的引用的地方。简而言之,ref用于让mongoose知道在使用.populate()之类的内容时要填充的模型。

例如,假设您的模型名称为ref。如果您想查找所有树,并填写与每个Tree相关联的每个branch的所有信息,您将使用以下代码:

tree
相关问题