{
'_id':'001',
'name':'Commitee One',
'members':[
{ '_id':'101', 'name':'Freddy' },
{ '_id':'102', 'name':'Barney' },
]
}
{
'_id':'002',
'name':'Commitee Two',
'members':[
{ '_id':'103', 'name':'Wilma' },
{ '_id':'101', 'name':'Freddy' },
]
}
db.test.find({'members.name':'Freddy'}) will return both committees.
( overstating the obvious... )
If I want to update the name Freddy to Fred... not replace the whole
sub document, just $set the name ( am using php, if that matters )
$groups->update( array( 'members.name'=>'Freddy' ), array( '$set' =>
array("members.1" => array("name" => "Fred"))) )
won't work. Fred is at index 0 for the first document, and index 1 of
the second.
Can I target multiple sub objects in multiple records in one update ?
Can I directly obtain the array index of a sub document?
--
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.