mongodb - Mongo - Select document not having a particular key value pair -


this sample document in collection collection consists of multiple documents below document variable array elements in "genericparams".-

"currentstate" : {                 "genericparams" : [                     {                         "key" : "sms_email_count",                         "value" : 3                     },                     {                         "key" : "first_sms_email_time",                         "value" : numberlong("1450691202568")                     },                     {                         "key" : "second_sms_email_time",                         "value" : numberlong("1450691202568")                     },                     {                         "key" : "third_sms_email_time",                         "value" : numberlong("1450691202568")                     },                     {                         "key" : "manual_refund_processed",                         "value" : "false"                     }                 ]             } 

i want get such documents "key" not equal "manual_refund_processed".
@ same time want elements of "genericparms" array thats why did not use $unwind. have tried -

  1. "currentstate.genericparams.key": { $exists: true, $ne: "manual_refund_processed" }
  2. "currentstate.genericparams.key": { $exists: true, $nin: [ "manual_refund_processed" ] }

try filters: https://docs.mongodb.org/manual/reference/operator/aggregation/filter/

        $filter: {            input: "$genericparams",            as: "genericparam",            cond: { $ne: [ "$$genericparam.key", "manual_refund_processed" ] }         } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -