Answer the question
In order to leave comments, you need to log in
How to make a request to mongo?
Hello! You need to make a request to mongo, I don’t understand how to do it:
First, about the structure of the document: route.stations[].id
route - bus route object
stations - array of stations in the route.
id - unique identifier of the station, integer
You need to select a route that contains 2 stations at the same time. That is, in the array of stations there is both one and the other station at the same time.
I try like this:
db.Bus.find({
"route.stations.id" : {$in : [1045, 7045]}
})
Answer the question
In order to leave comments, you need to log in
More or less like this:
db.Bus.find({
$and: [
{"route.stations.id": {$in : [1045]}},
{"route.stations.id": {$in : [7045]}}
]
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question