As part of another question I am trying to promisify a mongo/mongoose find query. I found little help via the search bar. The query is below, I am running this query as part of a controller in express. Setup is route -> userController.monitor which needs to contain the query
In getting help for the other question I was asked to promisify find so that you can use await for it (like const incidents = Incident.find({fooID}).exec();
though SO search and my attempts at promisifying it myself have failed.
Query:
Incident.find({fooID})
.exec((err, incidents) => {
// do something
})
Note a findOne will not work in this case because multiple documents will be returned almost all the time
Edit
Incident.find({ monitorID, createdAt: {$gte: sevenAgo} })