mquery
mquery copied to clipboard
Add support for findOneAndReplace?
I have been using Mongorito for some time now, and I really like it over some of the alternative node.js driver options out there. Mongorito uses mquery underneath the surface, which is great, since all of the mquery functionality is exposed.
I have on a growing number of occasions now run into a need for findOneAndReplace. This was added in MongoDB 3.2, and is one of the most useful update methods for me these days. I am not sure if there is a reason this operator has not been added, however i would love to see it added. I have multiple uses for it at the current time.
Sounds good. Please submit a PR.
You can use findOneAndUpdate with .setOptions({replace: true}) to achieve your goal. The replace option is only valid in mquery and support old MongoDB. It works as polyfill and maybe need to be updated to use latest driver version to enhance performance.