-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-402: Add aggregate helper to Database class #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
docs/includes/apiargs-MongoDBDatabase-method-aggregate-option.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
source: | ||
file: apiargs-aggregate-option.yaml | ||
ref: allowDiskUse | ||
--- | ||
source: | ||
file: apiargs-aggregate-option.yaml | ||
ref: batchSize | ||
--- | ||
source: | ||
file: apiargs-aggregate-option.yaml | ||
ref: bypassDocumentValidation | ||
--- | ||
source: | ||
file: apiargs-aggregate-option.yaml | ||
ref: comment | ||
--- | ||
source: | ||
file: apiargs-aggregate-option.yaml | ||
ref: explain | ||
--- | ||
source: | ||
file: apiargs-aggregate-option.yaml | ||
ref: hint | ||
--- | ||
source: | ||
file: apiargs-common-option.yaml | ||
ref: maxTimeMS | ||
--- | ||
source: | ||
file: apiargs-MongoDBDatabase-common-option.yaml | ||
ref: readConcern | ||
--- | ||
source: | ||
file: apiargs-MongoDBDatabase-common-option.yaml | ||
ref: readPreference | ||
post: | | ||
This option will be ignored when using the :ref:`$out <agg-out>` stage. | ||
--- | ||
source: | ||
file: apiargs-common-option.yaml | ||
ref: session | ||
--- | ||
source: | ||
file: apiargs-MongoDBDatabase-common-option.yaml | ||
ref: typeMap | ||
--- | ||
source: | ||
file: apiargs-MongoDBDatabase-common-option.yaml | ||
ref: writeConcern | ||
post: | | ||
This only applies when the :ref:`$out <agg-out>` stage is specified. | ||
|
||
This is not supported for server versions prior to 3.4 and will result in an | ||
exception at execution time if used. | ||
... |
14 changes: 14 additions & 0 deletions
14
docs/includes/apiargs-MongoDBDatabase-method-aggregate-param.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
arg_name: param | ||
name: $pipeline | ||
type: array | ||
description: | | ||
Specifies an :manual:`aggregation pipeline </core/aggregation-pipeline>` | ||
operation. | ||
interface: phpmethod | ||
operation: ~ | ||
optional: false | ||
--- | ||
source: | ||
file: apiargs-common-param.yaml | ||
ref: $options | ||
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
arg_name: option | ||
name: allowDiskUse | ||
type: boolean | ||
description: | | ||
Enables writing to temporary files. When set to ``true``, aggregation stages | ||
can write data to the ``_tmp`` sub-directory in the ``dbPath`` directory. The | ||
default is ``false``. | ||
interface: phpmethod | ||
operation: ~ | ||
optional: true | ||
--- | ||
arg_name: option | ||
name: batchSize | ||
type: integer | ||
description: | | ||
Specifies the initial batch size for the cursor. A batchSize of ``0`` means an | ||
empty first batch and is useful for quickly returning a cursor or failure | ||
message without doing significant server-side work. | ||
interface: phpmethod | ||
operation: ~ | ||
optional: true | ||
--- | ||
source: | ||
file: apiargs-MongoDBCollection-common-option.yaml | ||
ref: bypassDocumentValidation | ||
post: | | ||
This only applies when using the :ref:`$out <agg-out>` stage. | ||
|
||
Document validation requires MongoDB 3.2 or later: if you are using an earlier | ||
version of MongoDB, this option will be ignored. | ||
--- | ||
arg_name: option | ||
name: comment | ||
type: string | ||
description: | | ||
Users can specify an arbitrary string to help trace the operation through the | ||
database profiler, currentOp, and logs. | ||
interface: phpmethod | ||
operation: ~ | ||
optional: true | ||
--- | ||
arg_name: option | ||
name: explain | ||
type: boolean | ||
description: | | ||
Specifies whether or not to return the information on the processing of the | ||
pipeline. | ||
interface: phpmethod | ||
operation: ~ | ||
optional: true | ||
--- | ||
arg_name: option | ||
name: hint | ||
type: string|array|object | ||
description: | | ||
The index to use. Specify either the index name as a string or the index key | ||
pattern as a document. If specified, then the query system will only consider | ||
plans using the hinted index. | ||
interface: phpmethod | ||
operation: ~ | ||
optional: true | ||
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
============================== | ||
MongoDB\\Database::aggregate() | ||
============================== | ||
|
||
.. versionadded:: 1.5 | ||
|
||
.. default-domain:: mongodb | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
:class: singlecol | ||
|
||
Definition | ||
---------- | ||
|
||
.. phpmethod:: MongoDB\\Database::aggregate() | ||
|
||
Runs a specified :manual:`admin/diagnostic pipeline | ||
</reference/operator/aggregation-pipeline/#db-aggregate-stages>` which does | ||
not require an underlying collection. For aggregations on collection data, | ||
see :phpmethod:`MongoDB\\Collection::aggregate()`. | ||
|
||
.. code-block:: php | ||
|
||
function aggregate(array $pipeline, array $options = []): Traversable | ||
|
||
This method has the following parameters: | ||
|
||
.. include:: /includes/apiargs/MongoDBDatabase-method-aggregate-param.rst | ||
|
||
The ``$options`` parameter supports the following options: | ||
|
||
.. include:: /includes/apiargs/MongoDBDatabase-method-aggregate-option.rst | ||
|
||
Return Values | ||
------------- | ||
|
||
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` or | ||
:php:`ArrayIterator <arrayiterator>` object. In both cases, the return value | ||
will be :php:`Traversable <traversable>`. | ||
|
||
Errors/Exceptions | ||
----------------- | ||
|
||
.. include:: /includes/extracts/error-unexpectedvalueexception.rst | ||
.. include:: /includes/extracts/error-unsupportedexception.rst | ||
.. include:: /includes/extracts/error-invalidargumentexception.rst | ||
.. include:: /includes/extracts/error-driver-runtimeexception.rst | ||
|
||
.. _php-db-agg-method-behavior: | ||
|
||
.. todo: add examples | ||
|
||
See Also | ||
-------- | ||
|
||
- :phpmethod:`MongoDB\\Collection::aggregate()` | ||
- :manual:`aggregate </reference/command/aggregate>` command reference in the | ||
alcaeus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MongoDB manual | ||
- :manual:`Aggregation Pipeline </core/aggregation-pipeline>` documentation in | ||
the MongoDB Manual |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest double-checking to see if
explain
is compatible with any of the DB-level stages, but even if none of those are supported it's possible something is introduced in the future that does work withexplain
and might result in an ArrayIterator returned. I think we can leave this as-is. It's still accurate, even without the verbose "Behavior" section left in.