Open francois-spectre opened 1 year ago
6.6.1
16
5
In case of a removeMany with a filter query that returns no items, with mongoose v5 I got a success with deletedCount: 0. But with mongoose v6 I get an Error with the message {"acknowledged":true,"deletedCount":0}.
deletedCount: 0
{"acknowledged":true,"deletedCount":0}
I have investigated and here is the issue: https://github.com/graphql-compose/graphql-compose-mongoose/blob/919f28a96f5c55244f3169f3fb42ca8fef1e66e1/src/resolvers/removeMany.ts#L95 await beforeQueryHelper(resolveParams) returns:
await beforeQueryHelper(resolveParams)
{ n: 0, ok: 1, deletedCount: 0 }
With mongoose V6, do a mutation with a filter that match no items like
await client.mutate({ variables: {ids: []}, mutation: gql` mutation yourEntity($ids: [String]!) { removeMany(filter: { _operators: { _id: { in: $ids } } }) { numAffected } } ` })
I expect the same behaviour than with mongoose v5: getting a success response { n: 0, ok: 1, deletedCount: 0 }
They mentioned the change in mongoose v6 in the doc here: https://mongoosejs.com/docs/migrating_to_6.html#mongodb-driver-40
Mongoose version
6.6.1
Node.js version
16
MongoDB server version
5
Description
In case of a removeMany with a filter query that returns no items, with mongoose v5 I got a success with
deletedCount: 0
. But with mongoose v6 I get an Error with the message{"acknowledged":true,"deletedCount":0}
.I have investigated and here is the issue: https://github.com/graphql-compose/graphql-compose-mongoose/blob/919f28a96f5c55244f3169f3fb42ca8fef1e66e1/src/resolvers/removeMany.ts#L95
await beforeQueryHelper(resolveParams)
returns:{ n: 0, ok: 1, deletedCount: 0 }
.{"acknowledged":true,"deletedCount":0}
Steps to Reproduce
With mongoose V6, do a mutation with a filter that match no items like
Expected Behavior
I expect the same behaviour than with mongoose v5: getting a success response
{ n: 0, ok: 1, deletedCount: 0 }
They mentioned the change in mongoose v6 in the doc here: https://mongoosejs.com/docs/migrating_to_6.html#mongodb-driver-40