Saturday, 7 September 2013

mongoDb return results based on time interval

mongoDb return results based on time interval

I have this mongodb json data:
{'room' : '1', 'book_in_date' : '2013/09/11', 'book_out_date' : '2013/09/12'}
{'room' : '1', 'book_in_date' : '2013/09/15', 'book_out_date' : '2013/09/17'}
{'room' : '2', 'book_in_date' : '2013/09/11', 'book_out_date' : '2013/09/13'}
{'room' : '3', 'book_in_date' : '2013/09/20', 'book_out_date' : '2013/09/22'}
{'room' : '4', 'book_in_date' : '2013/09/09', 'book_out_date' : '2013/09/10'}
What I want to achieve is to get all rooms that conflicts with this time
interval:
book_in_date = 2013/09/11
book_out_date = 2013/09/13
In above data example the result will be: room1(first record),room2.
Is this possible in mongodb?

No comments:

Post a Comment