M
M
Messi2019-11-01 16:46:37
MongoDB
Messi, 2019-11-01 16:46:37

How to make double IN in Mongo?

There is a collection:

_id car_id title properties
1    1       title1 {color: 1, type: 10}
2    2       title2 {internet: 2, type: 10}
3    3       title3 {color: 2}

There is a request that should get a list of data from this collection by filtering by properties.
For example, there is an array color(1,3,5) and type(10, 20) and with one request you need to get only those properties data which are in the array and color and type.
When asked to make one IN into which to insert 1,3,5,10,20 it will not be correct, because data will get that has either color or type or all together.
How can this be done in one query?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2019-11-01
@FitTech

.find({'properties.color': [1,3,5], 'properties.type': [10,20]})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question