Skip to content

Conversation

@GromNaN
Copy link
Owner

@GromNaN GromNaN commented Jun 23, 2023

No description provided.

Copy link
Collaborator

@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.

Suggestion to use reference priming

->setParameter('now', new \DateTime())
;
$qb = $this->createQueryBuilder()
->field('publishedAt')->lte(new \DateTimeImmutable()) // $$NOW is a MongoDB variable that returns the current date
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use reference priming to eagerly load all referenced authors:

Suggested change
->field('publishedAt')->lte(new \DateTimeImmutable()) // $$NOW is a MongoDB variable that returns the current date
->field('publishedAt')->lte(new \DateTimeImmutable()) // $$NOW is a MongoDB variable that returns the current date
->field('author')->prime(true)

Copy link
Owner Author

Choose a reason for hiding this comment

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

It looks like primers are only supported for TYPE_FIND_AND_UPDATE and TYPE_FIND_AND_REMOVE queries. This is a TYPE_FIND query 😬
https://github.com/doctrine/mongodb-odm/blob/2.5.x/lib/Doctrine/ODM/MongoDB/Query/Query.php#L213-L231

Copy link
Collaborator

Choose a reason for hiding this comment

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

For queries of TYPE_FIND, this is done in makeIterator, which is called from runQuery: https://github.com/doctrine/mongodb-odm/blob/2.5.x/lib/Doctrine/ODM/MongoDB/Query/Query.php#L399..L402

@GromNaN GromNaN marked this pull request as ready for review June 28, 2023 08:51
  - Upgrading masterminds/html5 (2.8.1 => 2.9.0)
  - Upgrading monolog/monolog (3.5.0 => 3.6.0)
  - Upgrading phpstan/phpstan-doctrine (1.3.64 => 1.3.65)
  - Upgrading phpstan/phpstan-symfony (1.3.9 => 1.3.12)
  - Upgrading symfony/cache (v7.0.4 => v7.0.6)
  - Upgrading symfony/cache-contracts (v3.4.0 => v3.4.2)
  - Upgrading symfony/config (v7.0.4 => v7.0.6)
  - Upgrading symfony/console (v7.0.4 => v7.0.6)
  - Upgrading symfony/dependency-injection (v7.0.4 => v7.0.6)
  - Upgrading symfony/doctrine-bridge (v7.0.5 => v7.0.6)
  - Upgrading symfony/error-handler (v7.0.4 => v7.0.6)
  - Upgrading symfony/event-dispatcher-contracts (v3.4.0 => v3.4.2)
  - Upgrading symfony/filesystem (v7.0.3 => v7.0.6)
  - Upgrading symfony/form (v7.0.4 => v7.0.6)
  - Upgrading symfony/framework-bundle (v7.0.4 => v7.0.6)
  - Upgrading symfony/http-client (v7.0.5 => v7.0.6)
  - Upgrading symfony/http-client-contracts (v3.4.0 => v3.4.2)
  - Upgrading symfony/http-foundation (v7.0.4 => v7.0.6)
  - Upgrading symfony/http-kernel (v7.0.5 => v7.0.6)
  - Upgrading symfony/mailer (v7.0.4 => v7.0.6)
  - Upgrading symfony/maker-bundle (v1.57.0 => v1.58.0)
  - Upgrading symfony/mime (v7.0.3 => v7.0.6)
  - Upgrading symfony/phpunit-bridge (v7.0.4 => v7.0.6)
  - Upgrading symfony/property-access (v7.0.4 => v7.0.6)
  - Upgrading symfony/property-info (v7.0.3 => v7.0.6)
  - Upgrading symfony/routing (v7.0.5 => v7.0.6)
  - Upgrading symfony/security-bundle (v7.0.5 => v7.0.6)
  - Upgrading symfony/service-contracts (v3.4.1 => v3.4.2)
  - Upgrading symfony/translation-contracts (v3.4.1 => v3.4.2)
  - Upgrading symfony/twig-bridge (v7.0.4 => v7.0.6)
  - Upgrading symfony/validator (v7.0.5 => v7.0.6)
  - Upgrading symfony/var-dumper (v7.0.4 => v7.0.6)
  - Upgrading symfony/var-exporter (v7.0.4 => v7.0.6)
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