Hello,
I’m a full stack development learner working on a group project. I’m currently attempting to create a function for our home page that uses .find() to pull all documents from our database using dynamic dates.On the home page of our app, we want to show all events from the database that fall between the day the page is loaded and 7 days from page load. I haven’t been able to find a way to get the $lte to be 7 days from now.Any help is greatly appreciated!
Thanks,
Kery
Here is my current code:
async function getRangeOfFuzes() {
const fuzes = await fuze.find()
let todayDate = new Date();
let oneWeekDate = new Date(+new Date() + 7*24*60*60*1000);
console.log(`todayDate is: ${todayDate}`);
console.log(`oneWeekDate is: ${oneWeekDate}`);
$elemMatch: {
startTime: {
$gte: todayDate
$lte: oneWeekDate
}
}
}
getRangeOfFuzes();