Skip to content

Conversation

rustagir
Copy link
Contributor

@rustagir rustagir commented Nov 1, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-44954
Staging - https://deploy-preview-60--docs-mongoid.netlify.app/interact-data/scoping/

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 Nov 1, 2024

Deploy Preview for docs-mongoid ready!

Name Link
🔨 Latest commit 78f7284
🔍 Latest deploy log https://app.netlify.com/sites/docs-mongoid/deploys/6729186469033d00080f1e1b
😎 Deploy Preview https://deploy-preview-60--docs-mongoid.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@mayaraman19 mayaraman19 left a comment

Choose a reason for hiding this comment

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

LGTM (after TODOs are filled in) left some soft suggestions!

:end-before: end-query-named-scope
:language: ruby
:dedent:

Copy link
Collaborator

Choose a reason for hiding this comment

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

S: Maybe add a bit more elaboration on what this query does, like

Suggested change
This query matches documents in which value of the ``country`` field is ``"Japan"`` and value of the ``genre`` field includes ``"rock"``.

You can define ``Proc`` objects and blocks in named scopes so that they
accept parameters and extend functionality.

This example defines a ``Band`` model that includes ``based_in`` scope,
Copy link
Collaborator

Choose a reason for hiding this comment

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

S:

Suggested change
This example defines a ``Band`` model that includes ``based_in`` scope,
This example defines a ``Band`` model that includes a ``based_in`` scope,

Comment on lines +98 to +102
You can direct {+odm+} to raise an error when a scope overwrites an
existing class method by setting the ``scope_overwrite_exception``
configuration option to ``true``.

.. TODO add link to config options page
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: add an example of using scope_overwrite_exception option (unless the link will include those)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this future page will include the example

field :name, type: String
field :active, type: Boolean

default_scope ->{ where(active: true) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q (not familiar with syntax): is default_scope a keyword here?

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 is the way to define a default scope. I can make this more clear in the content

the values given in the default scope if those values are literals, such
as boolean values or integers.

.. note:: Field and Scope Conflicts
Copy link
Collaborator

Choose a reason for hiding this comment

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

this section is super clear! :)

criteria as the default for any queries that use the model. Default
scopes return ``Criteria`` objects.

The following code defines a default scope on the ``Band`` model to only
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 defines a default scope on the ``Band`` model to only
The following code defines a ``default_scope`` on the ``Band`` model to only

Comment on lines 105 to 106
label.bands # Still displays the Band
label.reload.bands # Won't display the Band after reloading
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: include example output?

Copy link
Contributor Author

@rustagir rustagir Nov 4, 2024

Choose a reason for hiding this comment

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

I dont think we could show successive output from these calls, but ill make these code comments better.

Comment on lines 246 to 255
{+odm+} treats class methods on models that return ``Criteria`` objects
as scopes. You can chain these class methods when querying, as shown in
the following example:

.. literalinclude:: /includes/interact-data/scoping.rb
:start-after: start-class-methods
:end-before: end-class-methods
:language: ruby
:dedent:
:emphasize-lines: 7-9, 12
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q (again, maybe unfamiliarity with syntax): what methods are being chained in this example? I guess "chained" makes me imagine multiple class methods being used.

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 can reword! I guess in this example a method is being chained to Band but really its the first method.

@rustagir rustagir merged commit ca16168 into mongodb:standardized Nov 4, 2024
5 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.

2 participants