I have data saved in db as follow:
collection name: movies:
[
{id:1, name:"abch", start:"12:00 pm", end:"03:00 pm"},
{id:2, name:"Annabelle", start:"08:30 am", end:"10:00 am"},
{id:3, name:"Spider Man homecoming", start:"11:30 am", end:"03:00 pm"},
{id:4, name:"Grudge", start:"10:00 pm", end"00:00 am"}
]
I use filter on the movie's start time and end time, like this -- starting:"12:00 pm" ending:"00:00 am"
req.query = { starting:"12:00 pm", ending:"00:00 am" }
I want all the list of movies where the start and end timing is between req.query = { starting:"12:00 pm", ending:"00:00 am" }
Output data should be:
[
{id:1, name:"abch", start:"12:00 pm", end:"03:00 pm"},
{id:3, name:"Spider Man homecoming", start:"11:30 am", end:"03:00 pm"},
{id:4, name:"Grudge", start:"10:00 pm", end"00:00 am"}
]
The mongodb query I used is:
movies.aggregate([
$or: [
{"start":req.query.starting},{"end":req.query.ending}
]
])
But this does not work. I dont know how to do this and dont know where I am going wrong.
I dont want to use $dateFromSting or new Date() or ISODate()
Want to get output with the above and want it to get from mongodb queries. Need Help Please!!!