Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
fe7a1e85
Commit
fe7a1e85
authored
Apr 28, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding distinct
parent
04053e99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
README.md
README.md
+4
-0
Query.php
src/Jenssegers/Mongodb/Query.php
+14
-2
No files found.
README.md
View file @
fe7a1e85
...
...
@@ -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
src/Jenssegers/Mongodb/Query.php
View file @
fe7a1e85
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment