[JAVA-3371] The use of UpdateOneModel on MongoCollection#updateOne Created: 03/Aug/19 Updated: 06/Aug/19 Resolved: 06/Aug/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Shea Cartwright | Assignee: | John Stewart (Inactive) |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
N/A |
||
| Description |
|
Hey, I think it'd be cool if we were able to use the UpdateOneModel for MongoCollection#updateOne, I see this being pretty useful especially if you want to update a nested field based on if the document you're looking for is already there or not, so for one instance you'd use a push but the other you'd use a set one requiring an array filter and the other doesn't. Due to how it handles array filters if the array filter is unused it'll throw an exception, I think this would be a good way to avoid this as you can choose whether to have an array filter depending on the update. |
| Comments |
| Comment by John Stewart (Inactive) [ 06/Aug/19 ] |
|
sheacartwright4@gmail.com Thanks for your update. I will close this ticket. If you find that there is an argument to be made for adding this feature later down the road, please reopen the bug. |
| Comment by Shea Cartwright [ 06/Aug/19 ] |
|
It was just something to be slightly more convenient. I currently just use the getters on the UpdateOneModel to do this anyway, I also don't see many advantages to it now that you ask for some code to demonstrate it. I'll just continue you to use the getters and passing them through MongoCollection#updateOne. |
| Comment by John Stewart (Inactive) [ 06/Aug/19 ] |
|
The constructors for `UpdateOneModel` have the same parameters as the `MongoCollection#updateOne` parameters, so I do not see the advantage of passing an `UpdateOneModel` object as a parameter to `updateOne`. Could you provide some pseudocode that would illustrate the advantages of using UpdateOneModel in calls to `updateOne`? Thanks. |
| Comment by Shea Cartwright [ 03/Aug/19 ] |
|
Sorry didn't realise I set it to major priority, it's really not. I also want to say this could also be useful for all the other models which extend WriteModel and their counterpart methods. |