doug-martin / nestjs-query

Easy CRUD for GraphQL.
https://doug-martin.github.io/nestjs-query
MIT License
821 stars 142 forks source link

Problem with in operator and documents with array properties #1551

Open yoedusvany opened 2 years ago

yoedusvany commented 2 years ago

Hello

I'm having an issue with documents that have an array properties like that

document: person properties:

I want to filter with in operator over type property, posible values for this property are "part time", "full time", "remote"

The filter that I'm passing is:

'contracts.type': { in: ["part time", "full time"] }

but I'm getting the following error ERROR BadRequestException: unknown comparison field contracts.type

I tested it in the database

db.getCollection("person").find({ "contracts.type": { "$in": ["part time", "full time"] } })

and I got documents, so I think there is a problem with the library. I tested other operators like iLike, eq, and so on ok

I'm using the following versions

"@nestjs-query/core": "0.30.0",
"@nestjs-query/query-mongoose": "0.30.0",
TriPSs commented 2 years ago

If I would have to make a quess I think the filter is defined wrong and should look more like this:

{
  contracts: {
     type: { in: ["part time", "full time"] }
  }
}