-
Notifications
You must be signed in to change notification settings - Fork 7
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-41135: Specify Fields #8
Conversation
👷 Deploy request for docs-kotlin-sync pending review.Visit the deploys page to approve 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.
good work! a few small comments/questions
source/read/project.txt
Outdated
---------------- | ||
|
||
You can use a projection to specify which fields to include in a return | ||
document, or to specify which fields to exclude. You cannot combine inclusion and |
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: I'm unclear on whether "You cannot combine inclusion and exclusion statements..." means that I can combine both only if I am excluding the _id
field and nothing else (in my exclusion statement), or if I can combine both if I have an exclusion statement that excludes the _id
field as well as excluding other fields.
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.
C: Ok, reading further I now understand that the exclusion statement only applies to _id. You could potentially make that clearer earlier in the document.
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.
C: This also confuses me because it seems like, based on my understanding, the only time you'd combine includes and excludes statements is to exclude the _id field, as all other fields are implicitly excluded when you use a includes statement? Could you clarify when someone would want to use both an includes and excludes that didn't just exclude _id?
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.
The idea is that a standard query will pull all the document's fields, and once you apply a projection to specify the inclusion of a single field, all other fields automatically get excluded (except "_id").
Someone shouldn't want to use both an includes and excludes. I can try addressing this confusion by pulling up the clarifying text from below the page into this mention up here.
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.
yeah, I think moving the clarifying text up would be good.
source/read/project.txt
Outdated
.. code-block:: kotlin | ||
|
||
val projection = Projection.fields( | ||
Projections.include(<fieldName1>, <fieldName2>, ...), |
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 there supposed to be a comma at the end of this line?
Projections.include(<fieldName1>, <fieldName2>, ...), | |
Projections.include(<fieldName1>, <fieldName2>, ...) |
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 catch, can remove
source/read/project.txt
Outdated
When specifying fields to include, you can also exclude the ``_id`` field from | ||
the returned document. | ||
|
||
The following example performs the same query as the preceding example, but |
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.
The following example performs the same query as the preceding example, but | |
The following example runs the same query as the preceding example, but |
Exclude the ``_id`` Field | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
When specifying fields to include, you can also exclude the ``_id`` field from |
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: Can you only exclude the _id field when specifying fields to include, or can you exclude just the _id field without using any includes statements?
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
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
(cherry picked from commit 53751bb)
(cherry picked from commit 53751bb)
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-41135
Staging - https://preview-mongodbmcmorisi.gatsbyjs.io/kotlin-sync/DOCSP-41135-specify-fields/read/project
Self-Review Checklist