where() public méthode

Return a expression
public where ( $field, $value ) : Cursor | Expression
Résultat Cursor | Expression
 /**
  * Filter by id
  *
  * @param string|\MongoId $id id of document
  * @return \Sokil\Mongo\Cursor
  */
 public function byId($id)
 {
     if ($id instanceof \MongoId) {
         $this->expression->where('_id', $id);
     } else {
         try {
             $this->expression->where('_id', new \MongoId($id));
         } catch (\MongoException $e) {
             $this->expression->where('_id', $id);
         }
     }
     return $this;
 }
Exemple #2
0
 public function testPipeline_MatchExpression()
 {
     $pipeline = new Pipeline($this->collection);
     $expression = new Expression();
     $expression->where('a', 1)->whereLess('b', 12);
     $pipeline->match($expression);
     $this->assertEquals('[{"$match":{"a":1,"b":{"$lt":12}}}]', (string) $pipeline);
 }