-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Make writeConcern an optional named parameter for collection remove() #73
Comments
You are right, I'll change it to one pattern (named parameter). |
That sounds good! :) |
Hi Robert. |
Hi Vadim, okay, then I understand the origin of this. Yes that is correct, you can't use both optional and positional parameters at the same time unfortunately. I think you should make the remove selector mandatory, I don't know if you know this or not but it's easy to remove all documents by sending in an empty query like this to remove {} (or just drop the whole collection). Doing that would be consistent with how the Mongo CLI works, look at this example (you can test the same commands yourself):
As you can see in the command line interface both find and findOne have the query/selector as optional (same as mongo_dart) while remove has it mandatory (different from mongo_dart today). I thinking following that example would be the right thing to do, then the writeConcern can also be consistent with the other methods. |
In terms of consistency I think remove actually "belongs" with these commands: Methods using {WriteConcern writeConcern}:
They all do changes to the collection, they alter state in some way. The methods you mentioned using the pattern [selector]:
Are different because they don't change any state. I think it's more consistent for remove to use the same patterns as the other methods that change state. Although I think following the same pattern as the CLI commands is an even better argument. |
Robert, I've just read your last posts and, well, you are absolutely right. |
No problem, I think it's great that we can discuss these things here like this. Yes it's breaking indeed, I'm actually not sure how often it's used but yeah probably more often than find().stream. I think you did a good job on this previous change in terms of communication. I don't have the time right now to do this, but if you want I could maybe take a look at it in the future, can't say a specific date though. I'm quite busy at work at the moment. In terms of alleviating pain I think it's quite simple to tell people to replace any coll.remove() calls with coll.remove({}), a short explanation of how to update the method call I think would be good. Maybe it could be a good idea to also add an example to the comments on "remove" of how to remove all documents (so it shows up in the docs). Similar examples could also be added to find() and other as well to be honest, making it easier to newcomers. Maybe we could add a label called "0.3.0" to this issue, it's quite common in other Github repos to group issues based on versions I think. |
That's good plan I think. |
Agreed, sounds like a good plan! 👍 |
I think that we can go ahead and make this change. Something along the lines of: Future remove(SelectorBuilder selector, {WriteConcern writeConcern}); |
LGTM :) |
Sorry, got sick, and was also busy with school... Will drop in a PR today, plus tests. |
Great 👍 |
Wasn't able to get that in this week, still was busy. However, I'm heading on a 7-hour bus ride back home tomorrow, so I anticipate to have time to get this sent in. |
Resolved via 6b87d8d. |
It is possible to set writeConcern for the following methods on a collection object:
All but the remove method does this with an optional named parameter "writeConcern", only remove uses optional positional parameters.
I would like to propose that we change the writeConcern parameter for remove so that it is consistent with the other methods. What do you think @vadimtsushko? I don't know if you had some specific reason for this or if it's just how it became.
I know this would be a breaking change for users currently using the old style of the parameter, but I don't think it's that many that actually set it explicitly to be honest. I don't feel that this is a very urgent issue, but it would be good for the driver I think the more consistent it can be.
If you like the change, we could maybe add a version label (future mongo_dart version label) to this issue so it get implemented for the next bigger (and/or) breaking release. (Note: I can't add labels)
Edit: Replaced "delete" with "remove", was wrong to begin with
The text was updated successfully, but these errors were encountered: