Getting Specific Array Element - Meteor Mongodb -


i have structure

{ "_id" : "ebtlm2nmb79wwryer", "notificationbyusers" : {     "all" : [          {             "account_id" : "x5pjy66jawgoxdb4l",             "date" : isodate("2016-07-27t13:48:17.154z"),             "value" : null         },          {             "account_id" : "2c2fkxaktmermnt3e",             "date" : isodate("2016-07-27t13:53:10.296z"),             "value" : "instant"         },          {             "account_id" : "6np35oj63cavf4rhs",             "date" : isodate("2016-07-28t07:18:22.696z"),             "value" : "instant"         }     ] } 

}

and querying

db.collection.findone({_id: ebtlm2nmb79wwryer, 'notificationbyusers.all':{$elemmatch:{account_id: "2c2fkxaktmermnt3e"}}}, {_id:0, 'notificationbyusers.all.$': 1}) 

it returns in robomongo

{  "notificationbyusers" : { "all" : [      {         "account_id" : "2c2fkxaktmermnt3e",         "date" : isodate("2016-07-27t13:53:10.296z"),         "value" : "instant"     } ] } 

but in meteor returns array elements query. want result specific array element working in robomongo.

you can using fields projection, like:

mycollection.findone({},{ fields : {_id:0, 'notificationbyusers.all':1}}); 

this return object :

{  "notificationbyusers" : { "all" : [      {         "account_id" : "2c2fkxaktmermnt3e",         "date" : isodate("2016-07-27t13:53:10.296z"),         "value" : "instant"     } ] } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -