I have something like:
[
{
"_id" : "Person1",
"Age" : "20",
"Name" : "Dan",
"Hobbies" : [
{
"CId" : "42485756",
"What" : "Climbing",
"Where" : "Manchester"
},
{
"CId" : "00907616",
"What" : "Caving",
"Where" : "Dover"
}
]
}
]
Is there a command I can run to:
a) Change "Where" to "Folkestone" where _id is Person1, and
Hobbies.CId is 00907616
b) Add "What" as "UFO Sightseeing" in a new subobject where
Hobbies.CId is 24429897
and can the same command do both?
Cheers
--
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.
update({ "_id": "Person1", "Hobbies.Cld" : 00907616},
{"$set":{"Hobbies.$.Where": "Folkestone"}})
However, can I do this to update an entire person at once?
Say I wanted to update the age, name, add a surname, etc. I could do
that all in one command using $set.
Can I use one command to update the name, AND a hobby and possibly
another index child?
--
I know for sure I can't push one and update one.
I'm finding it difficult to update two in different indexes since $ is
only for one query...
--