TriPSs/nestjs-query

Filterable nested object in mongoose

iamkhalidbashir opened this issue · 9 comments

I could not find a way to make a property filterable for a sub-object of mongoose document. Only root properties seems to be filterable

TriPSs commented

Sub objects that can be filtered need to be defined with FilterableRelation for example, think in Mongoose this is maybe not always a actual relation but you can try that.

Screenshot from 2023-09-20 19-21-57

So is this warning in docs outdated?

TriPSs commented

No, that is probably correct.

I do not use mongoose so I do not know those parts.

Using dot notation didn't work?

Scott

Yes it did work, thanks.

TriPSs commented

Going to close this issue as it's resolved.

Actually its giving this error when call api call

Looks like it could not find a reference model, but there should be no reference model to search for as its a sub object

Error: Unable to lookup reference type for template"
1
: 
"    at MongooseQueryService.getReferenceModel (/home/node/app/packages/query-mongoose/src/services/reference-query.service.ts:339:11)"
2
: 
"    at MongooseQueryService.getReferenceQueryBuilder (/home/node/app/packages/query-mongoose/src/services/reference-query.service.ts:320:45)"
3
: 
"    at MongooseQueryService.findRelation (/home/node/app/packages/query-mongoose/src/services/reference-query.service.ts:138:40)"
4
: 
"    at /home/node/app/packages/query-graphql/src/loader/find-relations.loader.ts:34:47"

Using dot notation didn't work?

Could you please elaborate?
Dot notation using where?

I tried this, where whould I put dot notation?
image

I see this "Virtual relations"
Should this be the solution for now ?
image