I am using NestJS/mongoose in my project. All straightforward filters are working fine, but when I try to filter with nested data. eg.
interface abc{
id: mongoose.Schema.Types.ObjectId
name: string
}
interface pqr{
prop1: string
prop2: string
prop3: abc
prop4: abc
}
interface xyz {
key1: string
key2: string
key3: pqr
}
While querying {"key3.prop3.id":new ObjectId("62ceb429804e78434d21af4e")}
responds with the correct result inside NestJS project. but if I query through a network request, I can't send ObjectID as it gets covered into a string and as a result, it responds with an empty array.
Is there any way to match both ObjectId as well as string for the query.
If any way to add an operator to change it to ObjectId will also be acceptable like
{"$or":[{"key3.prop3.id":{"$oid":"62ceb429804e78434d21af4e"}},...]}
will gets chnaged into
{"$or":[{"key3.prop3.id":new ObjectId("62ceb429804e78434d21af4e")},...]}