Skip to content
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

doc: Add cookbook about embedding referenced documents using $lookup #2655

Merged
merged 4 commits into from
Jun 27, 2024

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Jun 25, 2024

Q A
Type doc
BC Break no
Fixed issues -

Summary

On reviewing the aggregation stages reference, and in particular $lookup, @alcaeus and I decided that we needed more detailed documentation on this specific use case.

@GromNaN GromNaN requested a review from alcaeus June 25, 2024 19:19
@GromNaN GromNaN changed the title Add cookbook about embedding referenced documents using $lookup doc: Add cookbook about embedding referenced documents using $lookup Jun 25, 2024

In order to make tests, you can import the following documents:

.. code-block:: php
Copy link
Member Author

Choose a reason for hiding this comment

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

I will check how to collapse this less interesting code.

docs/en/cookbook/lookup-reference.rst Show resolved Hide resolved

[
[
'_id' => MongoDB\BSON\ObjectId('667b034c75590cbbe601061c'),
Copy link
Member Author

Choose a reason for hiding this comment

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

Not using the new keyboard to make is clear that's data dump and not actual instantiation of objects.

Comment on lines +482 to +485
->lookup('Order')
->alias('orders')
->localField('_id')
->foreignField('user');
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we have to set the collection name because the User class doesn't have an orders property mapping.

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

A few suggestions for improvements, but reads good so far!

docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
docs/en/cookbook/lookup-reference.rst Outdated Show resolved Hide resolved
@GromNaN GromNaN merged commit 8f38d7f into doctrine:2.9.x Jun 27, 2024
17 of 18 checks passed
@GromNaN GromNaN deleted the doc-cookbook-lookup branch June 27, 2024 11:50
@GromNaN GromNaN added this to the 2.9.0 milestone Jun 27, 2024
alcaeus added a commit that referenced this pull request Sep 6, 2024
* 2.9.x: (24 commits)
  Fix typo in code example (#2670)
  Label PRs about GH actions with "CI" (#2632)
  Review basic mapping (#2668)
  Fix wording (#2667)
  Add native type to private properties and final classes (#2666)
  Review and add tests on `ResolveTargetDocumentListener` (#2660)
  Remove soft-delete-cookbook (#2657)
  doc: Remove wakeup and clone cookbook (#2663)
  Modernize generated code for Hydrators (#2665)
  Add tests for introduction (#2664)
  doc: Review mapping ORM and ODM cookbook (#2658)
  doc: Review cookbook on blending ORM and ODM (#2656)
  doc: Review and test validation cookbook (#2662)
  Update custom mapping example (#2654)
  doc: Review Simple Search Engine Cookbook (#2659)
  doc: Add cookbook about embedding referenced documents using $lookup (#2655)
  doc: Add type to properties (#2652)
  doc: Review custom collections and repository docs (#2653)
  doc: Review Getting Started (#2650)
  Move annotations-reference to attributes-reference (#2651)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants