I have two schemas
childrenSchema = new Schema({
name: String
});
parentSchema = new Schema({
type: String,
children: [childrenSchema]
});
Now I want a method in childrenSchema
from which I retrieve the type of the parent. I guess it is something like
childrenSchema.methods.generateName = () => {
// get parent type
};
Do there exist a function like this.parent().type
, i.e.
childrenSchema.methods.generateName = () => {
// get parent type
return this.parent().type;
};