Nested object
See original GitHub issueI have a schema like this:
new Schema({
waitingList: {
__type__: {
current: {
__type__: [{
date: {
__type__: Date
},
user: {
__type__: ObjectId,
ref: "User"
},
}]
},
history: {
__type__: [{
date: {
__type__: Date
},
user: {
__type__: ObjectId,
ref: "User"
},
}]
}
}
},
}, {
autoIndex: true,
typeKey: "__type__"
});
So, in essence a sample document looks like this:
{
waitingList: {
current: [],
history: [{date: someDate, user: myUser}],
}
}
In that case I want to deep populate user
, but if I specify the path as "waitingList.history.user"
. The plugin crashes with error TypeError: Cannot read property 'paths' of undefined
at this position: https://github.com/buunguyen/mongoose-deep-populate/blob/0080a0949fef38bcb9541b267a55810c14c78d4c/lib/plugin.js#L260
For some funny reason I am restricted from declaring sub-schema for those embeded documents. It is possible to make it work in such case?
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Nested Objects - Learn JavaScript - Codecademy
In application code, objects are often nested— an object might have another object as a property which in turn could have a property...
Read more >Nested objects in javascript, best practices - Stack Overflow
I would like to know the correct way to create a nested object in javascript. I want a base object called "defaultsettings".
Read more >JSON nested objects - IBM
Objects can be nested inside other objects. Each nested object must have a unique access path. The same field name can occur in...
Read more >How to use Nested Objects in JavaScript - Linux Hint
In JavaScript, nested objects are used to store the properties of an object in another object. These objects are accessible via dot or...
Read more >Accessing Nested Objects in JavaScript - HackerNoon
Array reduce method is very powerful and it can be used to safely access nested objects. const getNestedObject = (nestedObj, pathArr) => { ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is this has solution?My code has same problems if key was named “type”.
@kevinresol I try to modify typeKey but deep-populate occurs error