getDistinct() 공개 메소드

Retrieve a list of distinct values for the given key across a collection.
public getDistinct ( string $selector, array | callable | Expression $expression = null ) : array
$selector string field selector
$expression array | callable | Expression expression to search documents
리턴 array distinct values
예제 #1
0
 public function testGetDistinct_NoExpression()
 {
     $this->collection->createDocument(array('k' => array('f' => 'F1', 'kk' => 'A')))->save();
     $this->collection->createDocument(array('k' => array('f' => 'F1', 'kk' => 'A')))->save();
     $this->collection->createDocument(array('k' => array('f' => 'F1', 'kk' => 'B')))->save();
     $this->collection->createDocument(array('k' => array('f' => 'F2', 'kk' => 'C')))->save();
     // get distinct
     $distinctValues = $this->collection->getDistinct('k.kk');
     $this->assertEquals(array('A', 'B', 'C'), $distinctValues);
 }