Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #234 from VoycerAG/comment-operator
Browse files Browse the repository at this point in the history
Add support for the $comment operator
  • Loading branch information
malarzm committed Oct 31, 2015
2 parents 556287a + 86ffa26 commit 23ff31f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Doctrine/MongoDB/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@ public function bitXor($value)
return $this;
}

/**
* Associates a comment to any expression taking a query predicate.
*
* @see Expr::comment()
* @see http://docs.mongodb.org/manual/reference/operator/query/comment/
* @param string $comment
* @return self
*/
public function comment($comment)
{
$this->expr->comment($comment);
return $this;
}

/**
* Change the query type to count.
*
Expand Down
14 changes: 14 additions & 0 deletions lib/Doctrine/MongoDB/Query/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ public function bitXor($value)
return $this->bit('xor', $value);
}

/**
* Associates a comment to any expression taking a query predicate.
*
* @see Builder::comment()
* @see http://docs.mongodb.org/manual/reference/operator/query/comment/
* @param string $comment
* @return self
*/
public function comment($comment)
{
$this->query['$comment'] = $comment;
return $this;
}

/**
* Sets the value of the current field to the current date, either as a date or a timestamp.
*
Expand Down
1 change: 1 addition & 0 deletions tests/Doctrine/MongoDB/Tests/Query/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ public function provideProxiedExprMethods()
'text()' => array('text', array('foo')),
'max()' => array('max', array(1)),
'min()' => array('min', array(1)),
'comment()' => array('comment', array('A comment explaining what the query does'))
);
}

Expand Down

0 comments on commit 23ff31f

Please sign in to comment.