I am using typegoose and my Query and QueryRule models are as below.
export class Query {
@prop()
queryRule: Ref<QueryRule>;
}
export class QueryRule {
@prop()
condition: Condition;
@prop()
rules: Ref<QueryRule | ChildRule>[];
}
I am using the following query to populate.
await QueryModel.findById(queryId).populate('queryRule');
My Query Document is as below.
{"_id":{"$oid":"6283d73baffa60c38af8c2f0"},"name":"test","queryRule":{"$oid":"6287c8f0e3ab4b5dd7238ef3"}}
My QueryRule Document is as below.
{"_id":{"$oid":"6287c8f0e3ab4b5dd7238ef3"},"condition":1,"rules":[],"__v":0}
But when I access condition and rules of QueryRule using populate query. I am getting undefined even though values exist in that document.
What am I doing wrong here?