I have a collection with field in following format
"hours": {
"Friday":{
"close":"12:30",
"open":"7:30"
}
I need to find if current time is between open and close. First of all I don't know what is good way to do this but i simply prepared a query like
query="{hours."currday()+".close:{gt:\""+currtime()+"\"}}";
where currday() and currtime() are javascript functions i wrote to give me name of day and time at the moment.
but now time is stored as a string and I cannot do gt to a string. I am not sure if my approach of writing js functions and preparing a query string is good one or not because I need to find most optimal way of running this query.
My first question is what is the most optimal way of doing this and second question is how do I perform something similar to between operator in sql. I am new to Mongo. Do you think i shall change structure of mongo collection or is there a way of writing query that will perform this operation.
I must repeat I am trying to find all documents whose day is current day and current time is between open and close time.