A
A
akamoroz2013-04-18 17:17:35
MongoDB
akamoroz, 2013-04-18 17:17:35

MongoDB: update on nested arrays

Hi all!
I can't figure out how to update correctly in this situation:
{ name: 'People', tasks: [ {title: 'First', subtasks: [{_id:1, title:'PLS UPDATE'}]}]}
update doesn't work in multilevel arrays : jira.mongodb.org/browse/SERVER-831

I can't do:
update({tasks.subtasks._id:1},{tasks.$.subtasks.$.title:'new value'})

Which crutch would be right here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jdponomarev, 2013-04-18
@jdponomarev

1 crutch - the first request to find out the position of the task in the array. update with the second request {tasks.number_in_array.subtasks.$.title:"new value"}
2 crutch - pull out all subtasks, update and write back.
choose :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question