Skip to content

DOCSP-39852: Fluent API #118

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 11 commits into from
Jun 11, 2024
Merged

Conversation

norareidy
Copy link
Collaborator

@norareidy norareidy commented Jun 4, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-39852
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/rust/DOCSP-39852-fluent-api/

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
Collaborator

@rustagir rustagir left a comment

Choose a reason for hiding this comment

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

Looks great, awesome work on this hefty PR - lmk if you want me to take another look after fixing small errors

chaining option builder functions one at a time.
.. note:: Setting Options

Beginning in {+driver-short+} v3.0, you can set ``FineOneAndDeleteOptions`` fields by
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: since this change will only appear in v3 docs, no need to specify the version

Suggested change
Beginning in {+driver-short+} v3.0, you can set ``FineOneAndDeleteOptions`` fields by
You can set ``FindOneAndDeleteOptions`` fields by

Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed this typo in other places as well, maybe Ctrl F to make sure it's spelled correctly everywhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops fixed!


The following table describes the options available in
``FineOneAndDeleteOptions``:
``FineOneAndUpdateOptions``:
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
``FineOneAndUpdateOptions``:
``FindOneAndUpdateOptions``:


The following table describes the options available in
``FindOneAndReplaceOptions``:
``FineOneAndReplaceOptions``:
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
``FineOneAndReplaceOptions``:
``FindOneAndReplaceOptions``:

creation of many different types, including ``FindOptions``. You can
use each type's ``builder()`` method to construct an options instance
by chaining option builder functions one at a time.
Beginning in {+driver-short+} v3.0, you can set ``FindOptions`` fields by chaining
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as earlier - remove

@@ -283,7 +288,7 @@ collection:
{ "_id": 3, "title": "Goodnight Moon" }

When you attempt to insert these documents, the result depends on the
value of the ``ordered`` option in your ``InsertManyOptions``:
``ordered`` value passed to the ``ordered()`` option builder method:
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
``ordered`` value passed to the ``ordered()`` option builder method:
value passed to the ``ordered()`` option builder method:

creation of many different types, including ``GridFsBucketOptions``. You
can use the ``builder()`` method to construct an instance of each type
creation of some struct types, including ``GridFsBucketOptions``. You can
use the ``builder()`` method to construct an instance of each type
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: just checking that the gridFS api is still using builders to create options

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it is

let filter = doc! { "year": 2015 };
let mut cursor = collection.find(filter, opts).await?;
let mut cursor = collection
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: with all these line changes, can you check that theres no code highlighting that was affected?

@abr-egn abr-egn self-requested a review June 7, 2024 19:21
source/faq.txt Outdated
@@ -134,7 +134,7 @@ and using the ``try_next()`` method to iterate over ``Actor`` instances causes a
// Add setup code here

let my_coll: Collection<Actor> = client.database("db").collection("actors");
let mut cursor = my_coll.find(None, None).await?;
let mut cursor = my_coll.find(None).await?;
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
let mut cursor = my_coll.find(None).await?;
let mut cursor = my_coll.find(doc! {}).await?;

doc! { "title": "Peter Pan" },
None
)?;
let result = collection.find_one(doc! { "title": "Peter Pan" })?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately, for the sync API the switch to fluent methods means they now need a .run() to execute; there's no natural terminator like .await is for the async API. So this becomes:

let result = collection.find_one(doc! { "title": "Peter Pan" }).run()?;

and similar for other places below.

@norareidy norareidy requested a review from abr-egn June 11, 2024 14:02
Copy link
Collaborator

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

LGTM!

@norareidy norareidy merged commit 48731de into mongodb:master Jun 11, 2024
2 checks passed
@norareidy norareidy deleted the DOCSP-39852-fluent-api branch June 11, 2024 15:36
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