mongoose-history-trace icon indicating copy to clipboard operation
mongoose-history-trace copied to clipboard

mongoose 6.5 not work

Open hmz22 opened this issue 2 years ago • 5 comments

in mongoose v6.5 show this error DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. please update mongoose 6 or new and when use findByIdAndUpdate in graphql show this error:

Error: \n    at model.Query._wrappedThunk [as _findOne] (D:\\Projects\\Tests\\node-ts-sample-decorator2\\node_modules\\mongoose\\lib\\helpers\\query\\wrapThunk.js:25:28)\n    at D:\\Projects\\Tests\\node-ts-sample-decorator2\\node_modules\\kareem\\index.js:426:25\n    at processTicksAndRejections (internal/process/task_queues.js:77:11)",
          "stacktrace": [
            "MongooseError: Query was already executed: Member.findOne({",
            "  _id: new ObjectId(\"6312eddb7ef718e09f7089...",
            "    at model.Query._wrappedThunk [as _findOneAndUpdate] (D:\\Projects\\Tests\\node-ts-sample-decorator2\\node_modules\\mongoose\\lib\\helpers\\query\\wrapThunk.js:21:19)",
            "    at D:\\Projects\\Tests\\node-ts-sample-decorator2\\node_modules\\kareem\\index.js:334:18",
            "    at _next (D:\\Projects\\Tests\\node-ts-sample-decorator2\\node_modules\\kareem\\index.js:128:16)",
            "    at D:\\Projects\\Tests\\node-ts-sample-decorator2\\node_modules\\kareem\\index.js:91:37",
            "    at processTicksAndRejections (internal/process/task_queues.js:95:5)

hmz22 avatar Sep 03 '22 06:09 hmz22

Experimenting same issue. Do you have any news on that?

const result = await MyModel.findByIdAndUpdate({...})

Mongoose version 6.8.0.

MongooseError: Query was already executed: certifications.findOne({ _id: new ObjectId("63ae2eeca15db2cb... at model.Query._wrappedThunk [as _findOneAndUpdate] (/home/marcbernal/ld-reporting-tool/node_modules/mongoose/lib/helpers/query/wrapThunk.js:23:19) at /home/marcbernal/ld-reporting-tool/node_modules/kareem/index.js:384:18 at _next (/home/marcbernal/ld-reporting-tool/node_modules/kareem/index.js:139:16) at /home/marcbernal/ld-reporting-tool/node_modules/kareem/index.js:102:37 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { originalStack: 'Error\n' + ' at model.Query._wrappedThunk [as _findOne] (/home/marcbernal/ld-reporting-tool/node_modules/mongoose/lib/helpers/query/wrapThunk.js:27:28)\n' + ' at /home/marcbernal/ld-reporting-tool/node_modules/kareem/index.js:384:18\n' + ' at /home/marcbernal/ld-reporting-tool/node_modules/kareem/index.js:110:15\n' + ' at process.processTicksAndRejections (node:internal/process/task_queues:77:11)'

marcbernalencora avatar Dec 30 '22 14:12 marcbernalencora

Problem already fixed, during this first week of 2023 I will release a new version, this version will be a breaking point, I removed some problematic features.

WelingtonMonteiro avatar Dec 31 '22 02:12 WelingtonMonteiro

That's great! Looking forward to it. Thanks and have a happy new year!!

marcbernalencora avatar Dec 31 '22 02:12 marcbernalencora

Hello @WelingtonMonteiro when are you going to release the new version? Thanks!!

mspapant avatar Jan 17 '23 17:01 mspapant

I still haven't released it because when testing it in the mongoose version, it triggered many errors, and the most serious one I saw was exactly the one mentioned, looking at the doc I saw that now multiple queries are no longer allowed in the same instance, therefore, this error is under analysis by the mongoose devs for release in plugins. I'll be waiting for new features to fix. Therefore, for now, the plugin only works in version < 6.

This weekend I will be releasing the new corrections.

https://mongoosejs.com/docs/migrating_to_6.html#duplicate-query-execution

WelingtonMonteiro avatar Jan 18 '23 15:01 WelingtonMonteiro