-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Several problems about shell and node-mongodb-native compatibility #109
Milestone
Comments
Fonger
changed the title
Several problems about compatibility
Several problems about shell and browser compatibility
Jul 31, 2018
In mongo shell and node-mongodb-native, there is no findOneAndRemove.
Only findOneAndDelete.
A bit of history, mquery/mongoose was ahead of the curve on fluid syntax.
Overall, if mquery is now significantly outdated, I'm in favor of a semver
major release to realign with MongoDB.
Should we add the findOneAndDelete alias to avoid confusion?
Sounds wise.
…On Mon, Jul 30, 2018, 7:02 PM Fonger ***@***.***> wrote:
1.
mquery uses findAndModify to support findOneAndUpdate and
findOneAndRemove.
findAndModify has been deprecated since node-mongodb-native 2.2
<http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#findAndModify>.
mquery has mongodb dependency 2.2+ so we should update it even though the
latest 3.1 still supports findAndModify.
2.
findOneAndUpdate: new vs returnOriginal vs returnNewDocument
- the new option is only valid for findAndModify
mquery currently use findAndModify to support findOneAndUpdate so
new is valid. If we update mquery to use findOneAndUpdate, new is
not valid any more. This is not consistent with either mongo shell
or node-mongodb-native
- returnOriginal is only valid for node-mongodb-native
<http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndUpdate>
- returnNewDocument is only valid for mongo shell
<https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndUpdate/>
This is so annoying. I don't know why mongodb use a lot of different
name for different environment. The worst thing is that returnOriginal
is opposite of returnNewDocument. We have to decide if we want to
support all of these syntax, or make a breaking changes.
3.
In mongo shell and node-mongodb-native, there is no findOneAndRemove.
Only findOneAndDelete. Should we add the findOneAndDelete alias to
avoid confusion?
4.
Add findOneAndReplace #104
<#104>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#109>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKLsl76Alws68lfbzmnJQ4qQY3Iz6svks5uL7rEgaJpZM4Vneli>
.
|
Fonger
added a commit
to Fonger/mquery
that referenced
this issue
Jul 31, 2018
Fonger
changed the title
Several problems about shell and browser compatibility
Several problems about shell and node-mongodb-native compatibility
Jul 31, 2018
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to discuss some problems I found so far
mquery
callsfindAndModify
internally to supportfindOneAndUpdate
andfindOneAndRemove
.findAndModify
has been marked as deprecated sincenode-mongodb-native
2.2.mquery
has mongodb dependency 2.2+ so we should update it even though the latest 3.1 still supports findAndModify.Returning modified document after update:
new
vsreturnOriginal
vsreturnNewDocument
new is valid for
findAndModify
in bothmongo shell
andnode-mongodb-native
.returnOriginal is only valid for
findOneAndUpdate
innode-mongodb-native
returnNewDocument is only valid for
findOneAndUpdate
inmongo shell
new is the only valid option in
mquery().findOneAndUpdate()
.This is inconsistent with either
mongo shell
ornode-mongodb-native
becausemquery
usefindAndModify
to supportfindOneAndUpdate
. If we update mquery to callfindOneAndUpdate
directly fromnode-mongodb-native
,new
is not valid anymore and we should usereturnOriginal
instead. This is a breaking change.This is so annoying. I don't know why mongodb uses different names for different environments. The worst thing is that
returnOriginal
is opposite ofreturnNewDocument
. We have to decide if we want to support all of these syntax, or make a breaking changes? Maybe we should support all of these syntax in different calls and throw an error if there is a conflict in options?If new is not defined in
findAndModify
options,mquery
defaults totrue
so it will return new modified data. Although we want to get modified document in most cases, this behavior is not the same with eithermongo shell
ornode-mongodb-native
that defaults tofalse
. They return old document by default.In mongo shell and
node-mongodb-native
, there is nofindOneAndRemove
. OnlyfindOneAndDelete
method exists. Should we addfindOneAndDelete
as alias to avoid confusion?Add
findOneAndReplace
Add support for findOneAndReplace? #104 I don't know how to usefindAndModify
to implement findOneAndReplace. Maybe just callfindOneAndReplace
fromnode-mongodb-native
like point 1. suggests?The text was updated successfully, but these errors were encountered: