'how do i use find() with mongoose to find by another field
I am trying to find subscriptions by MovieId,or MembeId this is the schema:
const SubscriptionSchema = new mongoose.Schema({
MovieId : String,
MemberId : String,
Date : Date
})
this is the server:
BL:
const getAllSubscriptionsByMovieId = function(movieid)
{
return new Promise((resolve,reject) =>
{
Subscription.find({MovieId : movieid}, function(err, data)
{
if(err)
{
reject(err)
}
else
{
resolve(data);
}
})
})
}
router:
router.route('/')
.get( async function(req,resp)
{
let data = await subscriptionsBL.getAllSubscriptionsByMovieId(movieid)
return resp.json(data);
})
what is wrong??
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
