1

I have this documents inside my db, example:

{x: 10, y: 20, val: "h"}
{x: 20, y: 70, val: "ho"}
{x: 30, y: 80, val: "hol"}
{x: 40, y: 90, val: "hola"}
{x: 50, y: 29, val: "holas"}

i want to get all the documents matching x and y values by passing an array, exampe:

[{x: 10, y 20},{x: 20, y 70}]

so to return me:

[{x: 10, y: 20, val: "h"},{x: 20, y: 70, val: "ho"}]

i have tryed in this way but doesn't work:

var ricerca = {
   $in: [{x: 10, y 20},{x: 20, y 70}]
};

db.collection('exampe').find(ricerca).toArray(...

1 Answer 1

1

you need to use $or

$or: [{x: 10, y: 20},{x: 20, y: 70}]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.