[SERVER-1699] Fill in _id value for inserted docs Created: 30/Aug/10 Updated: 03/Feb/17 Resolved: 03/Feb/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 1.6.1 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Scott Hernandez (Inactive) | Assignee: | DO NOT USE - Backlog - Platform Team |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
The _id value should be set in the document by the shell (driver) before it is sent to the server. > var test = {a:1}> db.test11.insert(test) — I would like to see the _id field after the insert > var test = {a:1}> db.test11.insert(test) |
| Comments |
| Comment by Tim van Elsloo [ 13/Jul/11 ] |
|
This actually does happen when you insert new objects using the PHP-driver, which is great. Since writes are very fast, most of the time _id is already set, even if you didn't provide the $safe-param (which you should do, if your application relies on this). Now, back to the shell-driver. This probably isn't working because (afaik) JS doesn't support pass-by-reference, which is needed to accomplish what you want. For example: PHP: function change($obj) { This will print something like array('foo' => 'foo'); However, this isn't possible in JS (there's no &-symbol either): ; function change(obj) { This will alert 'bar', because there's no such thing in JS. This would be great, but isn't possible without modifying the underlying js-engine. |