That returns an empty array, so it seems like it doesnt find these.
Input:
startDate: 2025-04-18T13:30:00.000Z
endDate: 2026-04-20T14:30:00.000Z
All entries:
_id: 65cd5b32c1f7e198b373591d
startDate: 2025-04-19T08:24:36.000+00:00
endDate: 2026-02-07T00:31:40.000+00:00
howManyPeople: 9
owner: "something@something.com"
__v: 0
_id: 65cf510f4624ae128a3f99fe
startDate: 2022-04-19T08:24:36.000+00:00
endDate: 2023-04-19T08:24:36.000+00:00
howManyPeople: 4
owner: "something@something.de"
__v: 1
This is also the same for just using the endDate or the startDate. Using $project will throw an exception
Code is this
const reservationss = await Reservation.aggregate([
{
$match :
{
startDate : { $gte : startDate , $lte : endDate },
endDate : { $lte : endDate , $gte : startDate }
}
}
])