Skip to content

How to eager load a many-to-many relation? #27

Description

@bertheyman

I've a many-to-many relation set up. I've tried two approaches to work with eager loading, but can't figure it out.

  1. This approach works, but not sure how I can apply eager loading for this:
craft.entries.section('relatedSection').relatedTo(entry).all()
// Result ok but doesn't pair with eager loading
  1. But have trouble with this one, while this might support eager loading:
entry.relatedSectionFieldName
// Result empty

For the regular relation, this last approach does work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions