I'm attempting to remove references to a document (for the purpose of removing said document) using a $pull
update query however nothing appears to be happening.
I can manually run the following Mongo query
db.collection.update({}, {
$pull: {
'field': {'$id': ObjectId("xxxxxxxx")}
}
}, false, true)
which works fine. Attempting to do the same in Doctrine's ODM yields neither the expected result or any error messages. Here's what we have so far
$id = new MongoId("xxxxxxxx");
$qb = $repo->createQueryBuilder();
$qb->update();
$qb->field('field')->pull(array('$id' => $id));
$qb->getQuery()->execute();
开发者_高级运维
Any hints about what I'm doing wrong?
Ah, finally found it after trawling through the Doctrine code...
Have to pass the multi
option through to MongoCollection::update()
$qb->getQuery(array('multiple' => true))->execute();
$friend = Zend_Registry::get('doctrine')->getDocumentManager()->createQueryBuilder('App\document\Message')->update()->field('unread')->set(TRUE)->field('viewer_id')->equals(10001)-> getQuery(array('multiple' => true))->execute();
精彩评论