R
R
Ruslan Khissamov2015-06-09 18:18:24
MongoDB
Ruslan Khissamov, 2015-06-09 18:18:24

Sampling data from MongoDB by date and its absence?

Hi all!
From the view table

{ 
         "start" : ISODate(), 
         "end" : ISODate() 
}

It is required to find an array of data in a given interval, this is easily solved using $lt, $gt.
How to include in this array when fetching data where end == null or undefined?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lega, 2015-06-09
@lega

You can optimize, store end=start, take this into account on the client.

R
Ruslan Khissamov, 2015-06-09
@Rushis

$or: [
{end: null},
{end: {$gt: ISODate()}}
]
So far I've decided this way, is there a more elegant method?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question