[SERVER-13509] locate mistake when using $ operation on arrays Created: 08/Apr/14 Updated: 10/Dec/14 Resolved: 08/Apr/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | KimShen | Assignee: | Thomas Rueckstiess |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
For Example: , {"name":"b","age":"99"}], , {"level":"b","name":"b","age":"99"}]} 2,Update document which I want locate {"name":"a","age":"99"}in "a" and {"level":"b","name":"b","age":"99"} in "b" , But the result is: , {"age":"100","name":"b"}], , {"age":"100","level":"b","name" :"b"}] " in "a" like above ... |
| Comments |
| Comment by KimShen [ 08/Apr/14 ] |
|
Thanks a lot. Please close this issue. |
| Comment by Thomas Rueckstiess [ 08/Apr/14 ] |
|
Hi, Our current implementation of the positional $ operator is documented here on our page on the $ query. The two relevant paragraphs are:
The $ sign is the index of the match in the first array, and it is a placeholder for a single value. So what you are trying to achieve is currently not possible with a single update and would require two updates, or rewriting the a and b arrays entirely as part of the update. A similar feature request to allow the positional operator for nested arrays is Thanks, |
| Comment by KimShen [ 08/Apr/14 ] |
|
Add Example: , { "name" : "b", "age" : "ab" } ], , { "level" : "b", "age" : "bb" } ] Then update: ,{"$set":{"a.$.age":"ax"}}) And result: , { "name" : "b", "age" : "ax" } ], , { "level" : "b", "age" : "bb" } ] If want locate document using two query in two arrays then update , that's mistake |
| Comment by KimShen [ 08/Apr/14 ] |
|
May be query for "a" locate "array index 1" and query for "b" locate "array index 2", that final location using "b" ? |