I currently have a Mongoose Event
document which has startTime
, endTime
, and duration
attributes. I am trying to perform a query in a node.js file that grabs all Events where the event's start time is before the current time stamp, and the event's end time is after the current time stamp plus the duration of the event. Therefore, my query depends on being able to perform a calculation that uses an attribute (duration
) from the events it is querying. Something along the lines of this:
const eventQuery = Event.find(query);
eventQuery.where('startTime').lte(currentTimeStamp);
eventQuery.where('endTime').gte(currentTimeStamp + event.duration);
However, I'm not sure what I should write instead of event.duration
, as the event has not yet been pulled at this point and rather I want to incorporate each candidate event's duration in the DB into the query somehow. Please let me know if this is possible somehow!
via user3802348
No comments:
Post a Comment