-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35937 aggregations builder 4.3 #2876
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
DOCSP-35937 aggregations builder 4.3 #2876
Conversation
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.
pretty much looks good, left a few comments/questions!
An aggregation pipeline is a data processing pipeline that takes documents | ||
as input, sequentially performs transformations and computations on the data, |
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.
An aggregation pipeline is a data processing pipeline that takes documents | |
as input, sequentially performs transformations and computations on the data, | |
An aggregation pipeline is a data processing pipeline that | |
sequentially performs transformations and computations on input data, |
This section features the following examples of common aggregation stages and | ||
of an aggregation pipeline: |
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.
This section features the following examples of common aggregation stages and | |
of an aggregation pipeline: | |
This section features the following examples, which demonstrate how to use common | |
aggregation stages and combine stages to make an aggregation pipeline: |
This example stage performs a similar grouping to an equivalent | ||
``distinct()`` query builder method. To learn more about the ``distinct()`` | ||
method, see the :ref:`laravel-distinct-usage` usage example. |
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.
This example stage performs a similar grouping to an equivalent | |
``distinct()`` query builder method. To learn more about the ``distinct()`` | |
method, see the :ref:`laravel-distinct-usage` usage example. | |
This example stage performs a similar task as the | |
``distinct()`` query builder method. To learn more about the ``distinct()`` | |
method, see the :ref:`laravel-distinct-usage` usage example. |
You can chain the ``project()`` method to your aggregation pipeline to specify | ||
which fields from the documents to display by this stage. | ||
|
||
To specify fields to include, pass the name of a field and a truthy value, |
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.
Q: could including words like "truthy" and "falsy" confuse readers?
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 think it's a relatively common term and not obscure jargon. I provided examples in the qualifying phrase immediately after. Let me know if you had something else in mind for clarifying this.
- Add the ``year`` field to the documents and set the value to the year | ||
extracted from the ``birthday`` field. |
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.
S: could be more descriptive
- Add the ``year`` field to the documents and set the value to the year | |
extracted from the ``birthday`` field. | |
- Add the ``birth_year`` field to the documents and set the value to the year | |
extracted from the ``birthday`` field. |
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.
If you change this, change the year_avg
field to birth_year_avg
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.
Thanks, will update the example to use birth_year and birth_year_avg field names.
- Match all documents in the collection since the ``match()`` stage | ||
is omitted. |
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.
Q: is this line necessary? It could be confusing to mention things that the pipeline does NOT include
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 thought it would be good to reinforce the information provided in the admonition in the Match Stage Example section. I think it is relevant to the description of what the pipeline does and might cause readers to question what documents are part of the pipeline if omitted.
Let me know if you think it would be better to omit it.
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 think it could work better as a note, potentially, but I am ok with leaving as is too!
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.
Good idea, will move it to an admonition.
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.
lgtm with a few small suggestions, also happy to discuss my last comment
|
||
In this guide, you can learn how to perform aggregations and construct | ||
pipelines by using the {+odm-short+} aggregation builder. The aggregation | ||
builder lets you use a typesafe syntax to construct a MongoDB |
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.
builder lets you use a typesafe syntax to construct a MongoDB | |
builder lets you use a type-safe syntax to construct a MongoDB |
performs transformations and computations on input data, and outputs the | ||
results as a new set of documents. |
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.
performs transformations and computations on input data, and outputs the | |
results as a new set of documents. | |
performs transformations and computations on input data, then outputs the | |
results as a new document or set of documents. |
An aggregation pipeline is composed of **aggregation stages**, which are | ||
operators that process input data and output data that the next stage uses as | ||
its input. |
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.
An aggregation pipeline is composed of **aggregation stages**, which are | |
operators that process input data and output data that the next stage uses as | |
its input. | |
An aggregation pipeline is composed of **aggregation stages**, which use | |
operators to process input data and produce data that the next stage uses as | |
its input. |
To specify an ascending sort, set the field value to the ``Sort::Asc`` enum. | ||
|
||
To specify a descending sort, set the field value to the ``Sort::Desc`` enum. |
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.
S; combine into one sentence to shorten this section/reduce breaks
- Match all documents in the collection since the ``match()`` stage | ||
is omitted. |
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 think it could work better as a note, potentially, but I am ok with leaving as is too!
The following function accepts the name of a field that contains a date | ||
and returns an expression that extracts the year from the date: |
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.
S: I think this section should provide an example of a functionality that is not directly achievable from one aggregation operator, $year
in this case. For example, could this example extract the year and add a fixed number to calculate something like the year they turned 18? Or a field to tell if they were born in the 20th century or 21st century or something like that.
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.
Thanks -- I think that's a great idea and I had thought of other ideas. However, I intentionally decided on something less complex to focus on documenting the custom operator factory usage.
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.
LGTM, with a suggestion.
**aggregation pipeline**. | ||
|
||
An aggregation pipeline is a data processing pipeline that sequentially | ||
performs transformations and computations on input data, then outputs the |
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.
"input data" sounds like data that you send with the command. It think this working could be better: "data from the MongoDB database"
Thanks for fixing the unit tests! |
JIRA: https://jira.mongodb.org/browse/DOCSP-35937
Staging:
https://preview-mongodbcchomongodb.gatsbyjs.io/laravel/DOCSP-35937-Aggregations-Builder-4.3/fundamentals/aggregation-builder/
Checklist