Commit fe7a1e85 authored by Jens Segers's avatar Jens Segers

Adding distinct

parent 04053e99
......@@ -89,4 +89,8 @@ Examples
})
->get();
**Distinct**
$users = Users::distinct('name')->get();
All basis insert, update, delete and select methods should be implemented. Feel free to fork and help completing this library!
\ No newline at end of file
......@@ -73,7 +73,7 @@ class Query extends \Illuminate\Database\Query\Builder {
// Get Mongo cursor
if ($this->distinct)
{
$cursor = $this->collection->distinct($this->columns, $this->compileWheres());
$cursor = $this->collection->distinct($this->distinct, $this->compileWheres());
}
else if(count($this->groups))
{
......@@ -204,6 +204,18 @@ class Query extends \Illuminate\Database\Query\Builder {
return $this;
}
/**
* Force the query to only return distinct results.
*
* @return Builder
*/
public function distinct($column = false)
{
$this->distinct = $column;
return $this;
}
/**
* Compile the where array
*
......@@ -311,4 +323,4 @@ class Query extends \Illuminate\Database\Query\Builder {
return new Query($connection);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment