mongoose-sequence icon indicating copy to clipboard operation
mongoose-sequence copied to clipboard

Query middleware support

Open ramiel opened this issue 7 years ago • 8 comments

Update counters on findOneAndUpdate and update Based on the work by @linusbrolin.

  • [x] Add tests
  • [x] Rebase on latest develop
  • [ ] Add tests for multi option (on update)
  • [ ] Add same functionality for referenced fileds
  • Try to avoid a query to know if the upsert inserted a document

ramiel avatar Aug 26 '16 11:08 ramiel

I found another bug, when using scoped counter (I never tested that before, my bad), where the reference value(s) would be null. I've fixed it in my fork (same branch as before), so you should probably update this PR to the latest code from my branch.

linusbrolin avatar Aug 26 '16 12:08 linusbrolin

I'll do, and I will add the related test

ramiel avatar Aug 26 '16 12:08 ramiel

Coverage Status

Coverage remained the same at 100.0% when pulling 12939b881f0d8be12e8769c6d477eda4be69beb4 on query-middleware-support into 727be42dd65110735017f84a870a8e933d7683ae on develop.

coveralls avatar Aug 26 '16 15:08 coveralls

Coverage Status

Coverage remained the same at 100.0% when pulling b50319d3722913d5f3e3d09d654a807b481c0e0d on query-middleware-support into 16e3d01e057bd847a12dfeed5e9e86ac808aff53 on develop.

coveralls avatar Aug 26 '16 15:08 coveralls

Coverage Status

Coverage remained the same at 100.0% when pulling 96d6639c28fb8f8b7c53ef32c87d793a8fadaada on query-middleware-support into 65ec0a147b3adc148556c6752aca67ef3e20ab79 on develop.

coveralls avatar Aug 26 '16 17:08 coveralls

Coverage Status

Coverage remained the same at 100.0% when pulling 98b11b87547f0d267259f6e40aceb1e9b97f54ac on query-middleware-support into 65ec0a147b3adc148556c6752aca67ef3e20ab79 on develop.

coveralls avatar Aug 26 '16 17:08 coveralls

any update ? It's still not working for findOneAndUpdate

blocks-master avatar Aug 21 '20 15:08 blocks-master

@ramiel I have now rebased my branch on the latest code from your master branch, and updated the code accordingly. https://github.com/linusbrolin/mongoose-sequence/tree/query-middleware-support It should work with the parallel_hooks option, but I have not added any tests for it due to limited amount of time. I am however using it in a work project and it is working there.

If you could add the needed tests then I would very much appreciate it, otherwise I'll see if I can find time to do that myself.

For now I have added a check for the multi option on update, and exit the hook if true. And I have not added support for updateMany either, yet, due to limited time.

But I honestly think we should at the very least get support for upserting single documents released now, as it's been 5 years since my original PR! Or if someone wants to help adding support for updateMany and update with multi: true?

Let me know what you think.

linusbrolin avatar Jun 15 '21 11:06 linusbrolin