kratos
kratos

Reputation: 2495

Unable to increment value in a doctrine mongo query

Looking at the example at: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html

I am unable to do a simple increment. That is the value of "votes" never changes. My document ID ($postID) is correct and I am able to fetch the document. Just unable to increment. Why is Mongo's documentation so out of whack??

$postID = "5121d0ad253b4af1d8000001";
 $dm = $this->get('doctrine.odm.mongodb.document_manager');
$post = $dm->createQueryBuilder('MainPostsBundle:Post')
->field('id')->equals($postID)
->field('votes')->inc(1)
->getQuery()->execute();

Upvotes: 2

Views: 1277

Answers (1)

Related Questions