My database has the following data stored:
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 applied a filter based on the movie's start time and end time as follows -- starting:"12:00 pm" ending:"00:00 am"
req.query = { starting:"12:00 pm", ending:"00:00 am" }
I am looking to retrieve the list of movies where the start
and end
timing is between
req.query = { starting:"12:00 pm", ending:"00:00 am" }
The desired 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
used was:
movies.aggregate([
$or: [
{"start":req.query.starting},{"end":req.query.ending}
]
])
However, this approach did not yield the expected results. I'm uncertain about my approach and seeking guidance.
I prefer not to use $dateFromSting
, new Date()
, or ISODate()
I aim to achieve the desired output using only mongodb queries. Any assistance would be greatly appreciated!