Skip to content

Aliases for eager expressions? #402

@koskimas

Description

@koskimas

What do you think about extending the eager expression language to support aliases:

const people = await Person
  .query()
  .eager(`[
    children as kids,
    parent as p .[
      pets(filterDogs) as dogs,
      pets(filterCats) as cats
    ]
  ]`);

console.log(people[0].p.dogs);

Combined with the new Model property namedFilters this would provide a pretty powerful and highly configurable graphql-like language. Competing with graphql is in no way a goal here, but this would be pretty easy to implement without complicating the codebase and could be really useful.

This was originally suggested by @allxie.

What do you think?

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