[SERVER-39975] update accepts true or an options document Created: 06/Mar/19 Updated: 10/Jul/19 Resolved: 07/May/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 4.0.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Frederik Gelder | Assignee: | Gabriel Russell (Inactive) |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Operating System: | ALL | ||||||||||||
| Steps To Reproduce: | create a database that has a collection called user_data (name doesnt matter) execute command:
you will get
execute command:
you will get
i would expect updateOne to do the same as update |
||||||||||||
| Sprint: | Dev Tools 2019-05-20 | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
for my project i needed to upsert into a set of values. i noticed that upserting didnt work when i was using updateOne, but it worked when i used update. this was done in the terminal, running mongodb shell 4.0.6. |
| Comments |
| Comment by Gabriel Russell (Inactive) [ 07/May/19 ] |
|
fredlllll The update command is older then the updateOne command. When the update command originally appeared, it had the api that you found on stack overflow. Eventually we realized that that api had limitations so we added a new bettter api and stopped recommending or documenting the old api. We left it in because we didn't want to break any existing code that people wrote and were using. Subsequently we developed updateOne and because there of course were not any prior uses of that command, we only wrote it for the newer api. Thank you for your bug report, but this looks to working correctly. Gabriel Russell |
| Comment by Frederik Gelder [ 07/Mar/19 ] |
|
so does this basically mean "user error"? i dont see it specified in the docs that a true can mean upsert too. i just saw the queries on stackoverflow using a true for upserting and it worked for update, so i didnt question it |
| Comment by Eric Sedor [ 06/Mar/19 ] |
|
See update and updateOne for the documented parameters. Currently, update not only accepts an options document (which may or may not include {upsert:true}, it can also accept true to specify an upsert. |