Child Object in Array Updating

201 views
Skip to first unread message

MiddleTommy

unread,
Aug 22, 2010, 2:06:14 AM8/22/10
to mongodb-user
What is the way to update a child object in an array?
Say I have posts with comments as an array in the posts collection. A
user wants to edit the comments he/she made. How do I reach into the
document and update that comment (provided the comment has unique
identifying fields natural or artificial)

Or do you find the whole post from mongodb; lookup the comment
locally; change it; then update the whole document back to the server?

Kristina Chodorow

unread,
Aug 22, 2010, 8:08:29 AM8/22/10
to mongod...@googlegroups.com
Check out the $ operator: http://www.mongodb.org/display/DOCS/Updating#Updating-The%24positionaloperator



--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


MiddleTommy

unread,
Aug 23, 2010, 12:26:22 AM8/23/10
to mongodb-user
Thanks thats just what I needed.
Reply all
Reply to author
Forward
0 new messages