S
S
Stanislav2017-01-21 23:26:51
MongoDB
Stanislav, 2017-01-21 23:26:51

How to find a document in a multidimensional array?

Can someone tell me how to find the record.
There are documents like

{
    _id: $id,
    times: 
}

[6, 3, 23]
1 Digit day of the week
2 Time from
3 Time to
You need to get a record that will correspond to the day of the week and the time period
. get an entry whose first digit is 6, the second digit is 3 or more, and the third digit is 23 or less.
That's about what I want to achieve, but of course this option does not work
{
"times": [6, {$gte: 3}, {$lte: 23}]
}

I tried in different ways, but I did not come to the desired result, is it possible to carry out such a search in mongo? Or do the documents need to be redone?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav, 2017-01-22
@ms-dred

Changed the selection to an array of objects

{
    times: [{
        week: { type: Number},
        s: { type: Number},
        e: { type: Number}
    }]
}

This option is easier, but I would like to find a solution for the first option, maybe someone will tell you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question