Answer the question
In order to leave comments, you need to log in
How to properly organize free/busy/reserve statuses in time periods on mongodb?
There are models in the database, you need to make statuses for them: free, busy and reserve.
Search (selection) interface:
- indicate dates from and to
- indicate the checkbox "including the reserve"
Mongo does not know how to do joins, what is the right thing to do here?
Store in date array? But how do you sample?
Let's say one record has
dates field/data: [
[2015-01-01, 2015-01-07],
[2015-02-01, 2015-02-07],
[2015-06-01, 2015-06-07 , 'reserv'],
[2015-09-01, 2015-09-17],
]
If the date is in the array and there is no "reserv" label, it is busy,
If there is a "reserv" label, then reserve
If there is no period at all, then free.
MongoDB should take the first value from the array, check if the period is there or not AND if there is a label or not. If you do not fall into any period, then the record must be returned.
Is there any operator in mongodb that walks through an array in a similar way? Or maybe there is another way to store all this and make a selection?
Thanks
Answer the question
In order to leave comments, you need to log in
Is there any operator in mongodb that walks through an array in a similar way?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question