Skip to content

Conversation

rustagir
Copy link
Contributor

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

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?
  • Are the facets and meta keywords accurate?

Copy link

netlify bot commented Jul 24, 2024

👷 Deploy request for docs-kotlin-sync pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit dd4a792

@rustagir rustagir marked this pull request as ready for review July 24, 2024 17:50
Copy link
Collaborator

@shuangela shuangela left a 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")
Copy link
Collaborator

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

Copy link
Collaborator

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"

Copy link
Contributor Author

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
Copy link
Collaborator

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.

----------------------

The ``insertOne()`` method optionally accepts a parameter
that sets options to configure the insert operation.
Copy link
Collaborator

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.

Modify Insert Behavior
----------------------

The ``insertOne()`` method optionally accepts a parameter
Copy link
Collaborator

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

Modify Insert Example
~~~~~~~~~~~~~~~~~~~~~

The following code creates options and uses the ``bypassDocumentValidation()`` method to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The following code creates options and uses the ``bypassDocumentValidation()`` method to
The following code sets the ``bypassDocumentValidation()`` option to

Copy link
Contributor Author

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.

You can use the following methods to retrieve information from
an ``InsertOneResult`` instance:

- ``getInsertedId()``, which indicates the ``_id`` value of the inserted document
Copy link
Collaborator

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

@rustagir rustagir requested a review from shuangela July 24, 2024 21:00
Copy link
Collaborator

@shuangela shuangela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@rustagir rustagir requested a review from rozza July 25, 2024 21:10
Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rustagir rustagir merged commit b122b68 into mongodb:master Jul 30, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants