mongodb - Meteor/Mongo DB $gte operator not working on find(); -


i trying make query return 'productos' on current 'categoria', need have 'stock.cantidad' field greater or equal 1 , 'stock.idcedis' equal specific value, , how trying it:

return productos.find(         {           idcategoria: router.current().params._id,           "stock.cantidad":{$gte: 1},           "stock.idcedis":idcedis         }); 

i checked , "stock.idcedis":idcedis working fine displaying 'productos' have specific 'idcedis', having problems "stock.cantidad":{$gte: 1}, part because don't know why meteor or mongo db matter ignoring it.

the schema stock part of 'productos' using this:

stock: {     type: [object]   },     "stock.$.cantidad": {       type: number,       label: "cantidad de stock",       min: 0     },     "stock.$.idcedis": {       type: string,       label: "centro de distribuciĆ³n"     }, 

so know if doing wrong or other way make work, in advance!

since stock.$.cantitad array try $elemmatch:

return productos.find(         {           idcategoria: router.current().params._id,           "stock.cantidad":{$elemmatch {$gte: 1}},           "stock.idcedis":idcedis         }); 

the mongo docs indicate shouldn't need when there's single query condition given how meteor interacts mongo i'd give try.

con mucho gusto.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -