M
M
Michael2016-09-12 21:11:01
MongoDB
Michael, 2016-09-12 21:11:01

How to write a query in MongoDB?

Hello. Working with MongoDB using Node.js. The data is stored in this form:

{
 id: '1',
 cars: [{color: 'red', price: 1 }, {color: 'blue', price: 2}]
}

And there is some func() function. I need to find all users who have at least one such car, when passing the value of the price field of which to this function, I will get, say, the value 10.
How to solve?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
catHD, 2016-10-10
@catHD

  1. Mongoose => Find => callback(Res.length)
    "How to write a query in MongoDB correctly?" - right! Use either Native/Mongoose and set limit)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question