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
497c0f30
Commit
497c0f30
authored
Jul 31, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added skip to aggregation
parent
92754b8e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
Builder.php
src/Jenssegers/Mongodb/Builder.php
+6
-5
Connection.php
src/Jenssegers/Mongodb/Connection.php
+2
-2
ModelQueryTest.php
tests/ModelQueryTest.php
+10
-0
No files found.
src/Jenssegers/Mongodb/Builder.php
View file @
497c0f30
...
...
@@ -18,12 +18,12 @@ class Builder extends \Illuminate\Database\Query\Builder {
* @var array
*/
protected
$conversion
=
array
(
'='
=>
'='
,
'='
=>
'='
,
'!='
=>
'$ne'
,
'<>'
=>
'$ne'
,
'<'
=>
'$lt'
,
'<'
=>
'$lt'
,
'<='
=>
'$lte'
,
'>'
=>
'$gt'
,
'>'
=>
'$gt'
,
'>='
=>
'$gte'
,
);
...
...
@@ -121,7 +121,8 @@ class Builder extends \Illuminate\Database\Query\Builder {
// Apply order and limit
if
(
$this
->
orders
)
$pipeline
[]
=
array
(
'$sort'
=>
$this
->
orders
);
if
(
$this
->
limit
)
$pipeline
[]
=
array
(
'$limit'
=>
$this
->
limit
);
if
(
$this
->
offset
)
$pipeline
[]
=
array
(
'$skip'
=>
$this
->
offset
);
if
(
$this
->
limit
)
$pipeline
[]
=
array
(
'$limit'
=>
$this
->
limit
);
$results
=
$this
->
collection
->
aggregate
(
$pipeline
);
...
...
@@ -150,7 +151,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
// Apply order, offset and limit
if
(
$this
->
orders
)
$cursor
->
sort
(
$this
->
orders
);
if
(
$this
->
offset
)
$cursor
->
skip
(
$this
->
offset
);
if
(
$this
->
limit
)
$cursor
->
limit
(
$this
->
limit
);
if
(
$this
->
limit
)
$cursor
->
limit
(
$this
->
limit
);
// Return results
return
iterator_to_array
(
$cursor
,
false
);
...
...
src/Jenssegers/Mongodb/Connection.php
View file @
497c0f30
...
...
@@ -105,14 +105,14 @@ class Connection extends \Illuminate\Database\Connection {
$dsn
.=
"
{
$username
}
:
{
$password
}
@"
;
}
$dsn
.=
"
{
$host
}
"
;
$dsn
.=
"
{
$host
}
"
;
if
(
isset
(
$config
[
'port'
]))
{
$dsn
.=
":
{
$port
}
"
;
}
$dsn
.=
"/
{
$database
}
"
;
$dsn
.=
"/
{
$database
}
"
;
return
$dsn
;
}
...
...
tests/ModelQueryTest.php
View file @
497c0f30
...
...
@@ -244,10 +244,20 @@ class ModelQueryTest extends PHPUnit_Framework_TestCase {
$users
=
User
::
groupBy
(
'age'
)
->
get
();
$this
->
assertEquals
(
6
,
count
(
$users
));
$users
=
User
::
groupBy
(
'age'
)
->
skip
(
1
)
->
get
();
$this
->
assertEquals
(
5
,
count
(
$users
));
$users
=
User
::
groupBy
(
'age'
)
->
take
(
2
)
->
get
();
$this
->
assertEquals
(
2
,
count
(
$users
));
$users
=
User
::
groupBy
(
'age'
)
->
orderBy
(
'age'
,
'desc'
)
->
get
();
$this
->
assertEquals
(
37
,
$users
[
0
]
->
age
);
$this
->
assertEquals
(
35
,
$users
[
1
]
->
age
);
$this
->
assertEquals
(
33
,
$users
[
2
]
->
age
);
$users
=
User
::
groupBy
(
'age'
)
->
skip
(
1
)
->
take
(
2
)
->
orderBy
(
'age'
,
'desc'
)
->
get
();
$this
->
assertEquals
(
35
,
$users
[
0
]
->
age
);
$this
->
assertEquals
(
33
,
$users
[
1
]
->
age
);
}
public
function
testSubquery
()
...
...
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