3
3
3042018-02-07 17:13:35
JavaScript
304, 2018-02-07 17:13:35

How to select multiple elements with different id in mongod?

There is a method in mongo client

db.users.find( { id: { $in: [ 390, 754, 454 ] } } );

Which allows you to select all elements with the specified id.
In the mongod driver for node js, there is a find method
db.collection("customers").find({id:390}, { _id: 0, name: 1 })

Is it possible to pass an array to it?
I mean something like this
db.collection("customers").find({id:[390,410,666]}, { _id: 0, name: 1 })

And how to make such a selection, if there is no such possibility?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2018-02-07
@304

db.collection("customers").find({ id: { $in: [ 390, 754, 454 ] } }, { _id: 0, name: 1 })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question