Reputation:
So I have a parameter
venue: {
type: mongoose.Schema.Types.ObjectId, ref: 'venue'
}
and I want to extract the id that is passed into the schema in a findById function like :
Event.
Venue.findById(id, callback).
populate('venue').
exec(function (err,event) {
if (err) return handleError(err);
});
I know this isn't correct code - how should I fix it?
Upvotes: 0
Views: 36
Reputation: 23515
Are you trying to get the value of the Event
plus the value of the Venue
behind the venue.id in Event
?
Event.findOne({
venue: id,
})
.populate('venue')
.exec()
.then((ret) => {
// ...
})
.catch((err) => {
// ...
});
Upvotes: 1