Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
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
PSDI Army
yii2
Commits
7314b5fe
Commit
7314b5fe
authored
Dec 06, 2013
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Options parameter added to "\yii\mogo\Collection::mapReduce()"
parent
0bd11926
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
Collection.php
extensions/mongo/Collection.php
+16
-1
No files found.
extensions/mongo/Collection.php
View file @
7314b5fe
...
...
@@ -522,10 +522,17 @@ class Collection extends Object
* @param string|array $out output collection name. It could be a string for simple output
* ('outputCollection'), or an array for parametrized output (['merge' => 'outputCollection'])
* @param array $condition criteria for including a document in the aggregation.
* @param array $options additional optional parameters to the mapReduce command. Valid options include:
* - sort - array - key to sort the input documents. The sort key must be in an existing index for this collection.
* - limit - the maximum number of documents to return in the collection.
* - finalize - function, which follows the reduce method and modifies the output.
* - scope - array - specifies global variables that are accessible in the map, reduce and finalize functions.
* - jsMode - boolean -Specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions.
* - verbose - boolean - specifies whether to include the timing information in the result information.
* @return string the map reduce output collection name.
* @throws Exception on failure.
*/
public
function
mapReduce
(
$map
,
$reduce
,
$out
,
$condition
=
[])
public
function
mapReduce
(
$map
,
$reduce
,
$out
,
$condition
=
[]
,
$options
=
[]
)
{
if
(
!
(
$map
instanceof
\MongoCode
))
{
$map
=
new
\MongoCode
((
string
)
$map
);
...
...
@@ -542,6 +549,14 @@ class Collection extends Object
if
(
!
empty
(
$condition
))
{
$command
[
'query'
]
=
$this
->
buildCondition
(
$condition
);
}
if
(
array_key_exists
(
'finalize'
,
$options
))
{
if
(
!
(
$options
[
'finalize'
]
instanceof
\MongoCode
))
{
$options
[
'finalize'
]
=
new
\MongoCode
((
string
)
$options
[
'finalize'
]);
}
}
if
(
!
empty
(
$options
))
{
$command
=
array_merge
(
$command
,
$options
);
}
$token
=
$this
->
composeLogToken
(
'mapReduce'
,
[
$map
,
$reduce
,
$out
]);
Yii
::
info
(
$token
,
__METHOD__
);
try
{
...
...
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