[DOCS-2446] using $set for arrays nested in arrays Created: 20/Dec/13 Updated: 20/Feb/14 Resolved: 10/Feb/14 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | mongodb-2.6 |
| Fix Version/s: | v1.3.1 |
| Type: | Tracking | Priority: | Major - P3 |
| Reporter: | Paul Gribelyuk | Assignee: | Kay Kim (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
windows 7 |
||
| Participants: | |
| Days since reply: | 9 years, 51 weeks, 6 days ago |
| Description |
|
I am trying to update a nested document structure which looks similar to this: ] What is the appropriate way to $set another field in the inner-most document, e.g. inner_inner_k3: inner_inner_v3? Thanks. |
| Comments |
| Comment by Githook User [ 20/Feb/14 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'tychoish', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 10/Feb/14 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 10/Feb/14 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by Kay Kim (Inactive) [ 16/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
Hi Paul – there's a change to the positional document that's undergoing review that will explicitly state this limitation : ) | |||||||||||||||||||||||||||||||||||
| Comment by Paul Gribelyuk [ 16/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
Thanks Kay. The documentation you linked doesn't state this explicitly, perhaps it should? Also, I don't need to determine the index of the inner_k2 array, I just want to add an element to it... not a field. Thus, going from a inner_k2 list of 1 item to a list of 2 items. Perhaps the confusion arises from mentining the $set operator, I think I might need to use $push instead. | |||||||||||||||||||||||||||||||||||
| Comment by Kay Kim (Inactive) [ 16/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
Hi Paul –
but, not for the elements of inner_k2. For more info on the positional operator, http://docs.mongodb.org/manual/reference/operator/update/positional/ | |||||||||||||||||||||||||||||||||||
| Comment by Paul Gribelyuk [ 16/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
Hi Kay, > { k1 : v1, , > ] | |||||||||||||||||||||||||||||||||||
| Comment by Kay Kim (Inactive) [ 16/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
Hi Paul – Did you mean:
You can use the dot notation to access array elements by its position: http://docs.mongodb.org/manual/core/document/#dot-notation However, if you don't know the actual position of the element you want to use, I believe currently the {$} positional operator does not work with nested arrays. | |||||||||||||||||||||||||||||||||||
| Comment by Sam Kleinman (Inactive) [ 07/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
I've edited the ticket title. I just want to make sure that specific questions get addressed outside of the documentation change process. We'll try and get this scheduled as soon as possible. | |||||||||||||||||||||||||||||||||||
| Comment by Paul Gribelyuk [ 07/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
Hi Sam, Perhaps the MongoDB docs would be improved by describing an answer to my question! -Paul | |||||||||||||||||||||||||||||||||||
| Comment by Sam Kleinman (Inactive) [ 07/Jan/14 ] | |||||||||||||||||||||||||||||||||||
|
The DOCS jira project is for issues and improvements in the MongoDB documentation. Questions like this are best addressed to one of our support channels: http://www.mongodb.org/about/support/ |