node.js - Find documents by an array of objects -


i want create query in mongodb to find documents , array of objects math document property.

i have documents:

{meta: {prop1: "hi1", prop2: "ho1"}}, {meta: {prop1: "hi2", prop2: "ho2"}}, {meta: {prop1: "hi3", prop2: "ho3"}}, {meta: {prop1: "hi1", prop2: "ho2"}} 

i want find documents meta property 1 of exact objects in array:

[   {prop1: "hi1", prop2: "ho1"}, {prop1: "hi2", prop2: "ho2"} ] 

desired result documents:

{meta: {prop1: "hi1", prop2: "ho1"}}, {meta: {prop1: "hi2", prop2: "ho2"}} 

but not:

{meta: {prop1: "hi1", prop2: "ho1"}}, {meta: {prop1: "hi2", prop2: "ho2"}}, {meta: {prop1: "hi1", prop2: "ho2"}} 

use $in operator.

collection.find({     meta:  {          $in: [             { prop1: 'hi1', prop2: 'ho1'},              { prop1: 'hi2', prop2: 'ho2'}         ]     }  }) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -