【发布时间】:2015-02-23 16:32:41
【问题描述】:
我有两个架构 Organization 和 Location。在 Organization 架构上,我引用了位置架构:
Organization = new Schema({
location: {
type: Schema.ObjectId,
ref: 'Location'
}
});
Location 架构包含国家、州、城市、地区等字段。
现在我将如何搜索带有特定国家或州或城市的Organization。
我在猫鼬文档中找到的是这样的:
Organization
.find()
.populate([{path:'location',select:'country state city district' },
{/*other population paths*/}] /*Some constriants here*/).exec(function(err, orgs){
console.log(orgs);
});
我如何实现这种类型的搜索。是否有任何插件可用于此类参考文档搜索?
【问题讨论】: