Instead of asking for a single date, you can request a date range that includes all of today's. First, you will need to create values ββfor this range - I whipped it with Moment, but probably the best way:
var begin = moment(moment().format("YYYY-MM-DD")).toISOString(); var end = moment(moment().format("YYYY-MM-DD")).add(1, 'days').toISOString();
Then you can use query operators to search for a range:
var queryObj = {date: {'>=': begin, '<': end}}; Day.findOrCreate(queryObj, newDay).exec(function(err, day) { console.log(day) });
As always, be aware of problems with the time zone!
source share