I have been trying to retrieve some data but i keep getting an error. Here's a snippet from my routes, please let me know what's wrong with it. I'm trying to get jobID from collection 2 which is represented by category in collection 1. Hope it makes sense.
I get this error UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: The 'cursor' option is required, except for aggregate with the explain argument
router.get('/jobs/:type', (req, res, next)=>{
Job.aggregate([
{ $match : { category: req.params.type, "bidcounter": { $gt:-1, $lt:5} } },
{
$lookup:
{
from: "job_cat",
localField: "category",
foreignField: "jobID",
as: "product_cat"
}
}, { $sort : { date : -1} }
], function(err, jobs){
res.json(jobs);
});
});