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 -
"currentstate.genericparams.key": { $exists: true, $ne: "manual_refund_processed" }
"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
Post a Comment