I have a model which contains this attribute amongst regular ones:
const dog = new mongoose.Schema({
name: {type: String, required: true},
roots: [{
_id: false,
race: { type: Schema.Types.ObjectId, ref: 'Race'},
origin: { type: Schema.Types.ObjectId, ref: 'Origin'}
}]
});
now I want to populate both of these nested properties. I tried it like this:
let dogList = await dog.find({'active': true}).deepPopulate('roots.race', 'roots.origin');
but then I always get the following error:
Mongoose: races.find({ _id: { '$in': [ ObjectId("5c102487c8381190b6183af7") ] } }, { fields: {} })
(node:40538) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '_id' of undefined
(node:40538) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The table which is mentioned in the exception is correctly spelled.
Hi
I have a model which contains this attribute amongst regular ones: const dog = new mongoose.Schema({ name: {type: String, required: true}, roots: [{ _id: false, race: { type: Schema.Types.ObjectId, ref: 'Race'}, origin: { type: Schema.Types.ObjectId, ref: 'Origin'} }] });
now I want to populate both of these nested properties. I tried it like this:
let dogList = await dog.find({'active': true}).deepPopulate('roots.race', 'roots.origin');
but then I always get the following error:
Mongoose: races.find({ _id: { '$in': [ ObjectId("5c102487c8381190b6183af7") ] } }, { fields: {} }) (node:40538) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '_id' of undefined (node:40538) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The table which is mentioned in the exception is correctly spelled.
Can you help me out?