php - MongoDB find count of all entries in child array by key -
i have collection in mongodb database looks this:
{ "_id": "0123456789", "merchants": { "13142": { "deeplink1": "http://xx.tld", "programid": 13142, "price": 24.9, "ean": "0123456789", "shipping": 0.0, "cf_farbe": "schwarz", "cf_geschlecht": "men", "cf_größe": "l", "cf_imgurl2": "http://img.tld", "cf_stamm-artikelnummer": "329830", "cf_verfügbare größen": "s, l" } } }
these merchant information products. _id
product code, "merchants" array merchant id key.
now need count of entries of merchant specific merchant id ("13142" example). how can perform (with php mongoclient class)?
thanks help!
db.collenctionname.find({'merchants.13142':{$exists:true}}).count()
give result in mongodb
console, please convert according php
.. in .net
cann't told php code..
use '.'
operator find inner level
property.. here in answer used 'merchants.13142'
Comments
Post a Comment