Skip to content

DOCSP-35962: sorts #2879

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 6 commits into from
Apr 19, 2024
Merged

DOCSP-35962: sorts #2879

merged 6 commits into from
Apr 19, 2024

Conversation

rustagir
Copy link
Contributor

@rustagir rustagir commented Apr 18, 2024

https://jira.mongodb.org/browse/DOCSP-35962

STAGING
DOCS PR

Checklist

  • Add tests and ensure they pass
  • Add an entry to the CHANGELOG.md file
  • Update documentation for new features

@rustagir rustagir requested a review from a team as a code owner April 18, 2024 14:28
Copy link
Contributor

@ccho-mongodb ccho-mongodb left a comment

Choose a reason for hiding this comment

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

LGTM! Left one suggestion.

Comment on lines 281 to 283
**descending** sort direction on results. By default, the ``orderBy()``
method sets an ascending sort on the supplied field name. To specify a
descending sort, pass ``'desc'`` as the second parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
I think the orderBy() method also accepts `asc' for ascending sort. It could be helpful to let the know the user exists (for completeness) and to mention that it's not necessary since it's the default value. I think keeping the asc examples as-is is fine though.

@rustagir rustagir requested review from a team, jmikola and GromNaN and removed request for a team and jmikola April 18, 2024 19:01

- :manual:`Natural order </reference/glossary/#std-term-natural-order>`
in the Server manual glossary
- `Ordering, Grouping, Limit and Offset <https://laravel.com/docs/10.x/queries#ordering-grouping-limit-and-offset>`__
Copy link
Member

Choose a reason for hiding this comment

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

The Laravel version in the doc url needs to be updated to 11.x for laravel-mongodb 4.2


.. code-block:: php

$movies = Movie::where('countries', 'Indonesia')
Copy link
Member

Choose a reason for hiding this comment

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

Could you move the examples to a test?

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 will move the query syntax examples into a test, but I'm not sure how to move the Controller method snippets into include files.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, let's keep the controller example here for now.

@rustagir rustagir requested a review from GromNaN April 18, 2024 20:26
Copy link
Member

@GromNaN GromNaN 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 fixing the Laravel doc link.


- :manual:`Natural order </reference/glossary/#std-term-natural-order>`
in the Server manual glossary
- `Ordering, Grouping, Limit and Offset <https://laravel.com/docs/11.x/queries#ordering-grouping-limit-and-offset>`__
Copy link
Member

Choose a reason for hiding this comment

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

That may be a subject to be dealt with separately, but we can't freeze the version like that. How to update the links when a new Laravel version is released? Perhaps the easiest way is to link to the latest version. But you run the risk of having a broken link.

Suggested change
- `Ordering, Grouping, Limit and Offset <https://laravel.com/docs/11.x/queries#ordering-grouping-limit-and-offset>`__
- `Ordering, Grouping, Limit and Offset <https://laravel.com/docs/queries#ordering-grouping-limit-and-offset>`__

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can link to the latest version, or we can store the laravel version as a source constant. Either way, the risk of linking to a broken link is there, so I'll update to just use latest for now.

// end-sort

$this->assertNotNull($movies);
$this->assertCount(4, $movies);
Copy link
Member

Choose a reason for hiding this comment

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

I've added fixtures to make the tests work. But I had to update the expected number of results, so we don't have too much data to load.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for fixing the tests!

// end-first

$this->assertNotNull($movie);
$this->assertInstanceOf(Movie::class, $movie);
Copy link
Member

Choose a reason for hiding this comment

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

I've renamed $movies into $movie, as a single object is expected. Not a list of 1.


.. code-block:: php

$movies = Movie::where('countries', 'Indonesia')
Copy link
Member

Choose a reason for hiding this comment

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

Ok, let's keep the controller example here for now.

@rustagir rustagir merged commit 21c9ca4 into mongodb:4.1 Apr 19, 2024
This was referenced Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants