[SERVER-26961] $unset by setting to undefined (like JSON.stringify does) Created: 09/Nov/16 Updated: 30/Dec/16 Resolved: 30/Dec/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Cyril Auburtin | Assignee: | David Storch |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
I think it would be interesting if
does the same than:
db.foo.updateOne({i:1}, {$set:{foo:7, bar:undefined}}) would be similar to JSON.stringify({foo:7, bar:undefined}) that have only the foo field |
| Comments |
| Comment by David Storch [ 30/Dec/16 ] | |||||||
|
Hi caub, After further review by the MongoDB Query Team, we have decided that we do not wish to implement this improvement. The canonical way to remove a field using the update subsystem will continue to be the $unset operator. If you wish to have this behavior as syntactic sugar, you can always implement the transformation on the client side as you suggested in your comment above. Best, | |||||||
| Comment by Cyril Auburtin [ 09/Nov/16 ] | |||||||
|
I think it's hard to do it because other languages don't have an undefined like JS, but I wish it would make its way in nodeJS driver In JS it's really practical to set to undefined before 'serialization' // this function can do the job too
|