I have the following data structure in a Meteor app, I would like to create a publication based on the "modelo" value.
{
"_id": "BAnLur25298ytvMdT",
"numero": "97",
"lienzos": 100,
"fechaCorte": "2016-03-29T00:00:00.000Z",
"modelos": [
{
"modelo": "95",
"distribucion": 100
},
{
"modelo": "96",
"distribucion": 100
}
],
"tela": "Jackard"
}
For example :
Meteor.publish('ModelosCorte', function(id) {
return CortesGeneral.find({
modelos: id
});
});
But I want to publish for example all CortesGeneral that have a "modelo": "96" as a value
You need to use dot notation to specify that you want to search for 'modelos.modelo'
. Give this a try:
Meteor.publish('ModelosCorte', function (id) {
check(id, String);
return CortesGeneral.find({ 'modelos.modelo': id });
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.