![](/img/trans.png)
[英]How to update array of embedded collection field based on another collection embedded field value in MongoDB?
[英]How to publish a collection based on a value of an array value
我在Meteor應用程序中具有以下數據結構,我想基於“ modelo”值創建發布。
{
"_id": "BAnLur25298ytvMdT",
"numero": "97",
"lienzos": 100,
"fechaCorte": "2016-03-29T00:00:00.000Z",
"modelos": [
{
"modelo": "95",
"distribucion": 100
},
{
"modelo": "96",
"distribucion": 100
}
],
"tela": "Jackard"
}
例如 :
Meteor.publish('ModelosCorte', function(id) {
return CortesGeneral.find({
modelos: id
});
});
但是我想發布例如所有具有“ modelo”:“ 96”作為值的CortesGeneral。
您需要使用點表示法來指定要搜索的'modelos.modelo'
。 試試看:
Meteor.publish('ModelosCorte', function (id) {
check(id, String);
return CortesGeneral.find({ 'modelos.modelo': id });
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.