-
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-41127: insert docs #20
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 job! some comments and questions
|
||
val mongoClient = MongoClient.create(uri) | ||
val database = mongoClient.getDatabase("sample_restaurants") | ||
val collection = database.getCollection<Restaurant>("restaurants") |
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.
suggestion: rename collection to "restaurants" so that it is clearer that we're inserting into the restaurants collection, especially since the user doesn't get to see the code declaring the collection/getting the collection
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 do this, change the code that says "collection" to "restaurants"
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 would prefer not to do this, as different pages use different sample data (this repo uses restaurants and movies off the top of my head). I dont think that the code examples here are supposed to necessarily be runnable, moreso demonstrate/explain the API for performing certain tasks.
I think keeping the variable name as collection
also makes it clear that you are performing the update operation on a MongoCollection
instance aka at the collection lvl
|
||
You can set the preceding settings on the ``insertMany()`` method | ||
by configuring an ``InsertManyOptions`` instance. You can also use the | ||
``ordered()`` method setter method to specify the order in which the driver |
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 ordered() only applicable to insertmanyoptions?
S: instead of having the ordered method be in the copy where people might overlook it, make a new table with just one entry and have the ordered() method in the table with a description.
source/write/insert.txt
Outdated
---------------------- | ||
|
||
The ``insertOne()`` method optionally accepts a parameter | ||
that sets options to configure the insert operation. |
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: Introduce InsertOneOptions as the name of the options class somewhere here. Currently, you only introduce it when you introduce the table, which is a little confusing.
source/write/insert.txt
Outdated
Modify Insert Behavior | ||
---------------------- | ||
|
||
The ``insertOne()`` method optionally accepts a parameter |
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: Clarify that the parameter is the second parameter that you pass into the method/last paramater
source/write/insert.txt
Outdated
Modify Insert Example | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The following code creates options and uses the ``bypassDocumentValidation()`` method to |
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 code creates options and uses the ``bypassDocumentValidation()`` method to | |
The following code sets the ``bypassDocumentValidation()`` option to |
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.
It might be confusing to use option and method interchangeably, I will workshop different phrasing.
source/write/insert.txt
Outdated
You can use the following methods to retrieve information from | ||
an ``InsertOneResult`` instance: | ||
|
||
- ``getInsertedId()``, which indicates the ``_id`` value of the inserted 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.
S: Make these a table rather than a bulleted list, for consistency
Applies to all
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!
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-41127
Staging - https://preview-mongodbrustagir.gatsbyjs.io/kotlin-sync/DOCSP-41127-insert/write/insert/
Self-Review Checklist