[JAVA-2128] Accept Documents for setOnInsert Created: 29/Feb/16 Updated: 05/Feb/19 Resolved: 21/Nov/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Builders |
| Affects Version/s: | 3.2.2 |
| Fix Version/s: | 3.10.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Ben [X] | Assignee: | Ross Lawley |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Updates.setOnInsert just accepts (String, TItem) as arguments. I think it would be developer friendlier to accept a Document, too. Add Updates.setOnInsert(Bson Items) as well for multiple fields that need to be set on insert. |
| Comments |
| Comment by Githook User [ 14/Jan/19 ] | ||
|
Author: {'username': 'rozza', 'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley'}Message: Ensure notNull in Updates.setOnInsert
| ||
| Comment by Githook User [ 14/Jan/19 ] | ||
|
Author: {'username': 'rozza', 'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley'}Message: Extended Updates.setOnInsert helper. It can now take a whole document.
| ||
| Comment by Githook User [ 21/Nov/18 ] | ||
|
Author: {'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}Message: Ensure notNull in Updates.setOnInsert
| ||
| Comment by Githook User [ 21/Nov/18 ] | ||
|
Author: {'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}Message: Extended Updates.setOnInsert helper. It can now take a whole document.
| ||
| Comment by Ross Lawley [ 01/Mar/16 ] | ||
|
Thanks for clarifying ChampS, sounds like it would be useful! | ||
| Comment by Ben [X] [ 01/Mar/16 ] | ||
|
Hi Ross and thanks for your quick reply, it's more like your second suggestion. I know I could use "new Document("$setOnInsert", myNewDoc)", but imho it also should work with the setOnInsert method. I think something like "Updates.setOnInsert(myNewDoc)" would be more java like. So this bug report is not about solving a problem, but improving the java driver if needed. best regards | ||
| Comment by Ross Lawley [ 29/Feb/16 ] | ||
|
Hi ChampS, The helper already accepts a document as the value for the key to be updated eg:
Or was it more that you wanted to pass a document of all the keys and values to be set?
I hope that helps, Ross |