【发布时间】:2012-03-20 17:10:55
【问题描述】:
我有以下嵌入另一个的 Mongoose 架构:
var EmbedSchema = new Schema({
foo: String
});
var ParentSchema = new Schema({
foo: String
embeds: [EmbedSchema]
});
在实例化和嵌入几个对象后,我将得到如下结果:
{
"_id": "4f505a866e65f3896b00002c",
"foo": "some value",
"embeds: [
{
"_id": "4f505aa36e65f3896b000034",
"foo": "some value 1"
}, {
"_id": "4f2eeb8f559757bf4f000001",
"foo": "some value 2"
}
]
}
embeds 中的_ids 在整个集合中是唯一的吗?我正在考虑仅使用 embeds._id 进行查询以获取 Parent(如果是)。
【问题讨论】: