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

Simpler Syntax for Inclusion #3205

Closed
3 tasks
nabdelgadir opened this issue Jun 21, 2019 · 1 comment · Fixed by #6866
Closed
3 tasks

Simpler Syntax for Inclusion #3205

nabdelgadir opened this issue Jun 21, 2019 · 1 comment · Fixed by #6866
Assignees
Labels
developer-experience Issues affecting ease of use and overall experience of LB users feature Repository Issues related to @loopback/repository package

Comments

@nabdelgadir
Copy link
Contributor

nabdelgadir commented Jun 21, 2019

Description / Steps to reproduce / Feature proposal

See https://github.com/strongloop/loopback-next/pull/3171/files#r296128644.

Currently to specify inclusion, the following filter syntax is needed: {include: [{relation: 'todos'}]} e.g. http://127.0.0.1:3000/todo-lists?filter[include][][relation]=todos

If we try the following call:

await todoListRepo.findById(todoList.id, {include: ['todos']});

The complier complains: Argument of type '{ include: string[]; }' is not assignable to parameter of type 'Filter<TodoList>' because the type is currently: include?: Inclusion<MT>[];

As LoopBack 3 supports {include: ['todos']}, LoopBack 4 should support this shortcut as well.

Acceptance Criteria

  • Update include to accept an array of model relation strings so that something like {include: ['todos']} is accepted.
  • Test coverage at both acceptance and integration level.
  • Update examples, tutorials and documentation to leverage the new simpler syntax wherever possible

Important: we need to preserve backwards compatiblity, i.e. the current verbose syntax must stay supported too.

@nabdelgadir nabdelgadir added feature Repository Issues related to @loopback/repository package labels Jun 21, 2019
@bajtos bajtos added developer-experience Issues affecting ease of use and overall experience of LB users 2019Q3 labels Jun 24, 2019
@bajtos
Copy link
Member

bajtos commented Jul 18, 2019

Few examples of the syntax supported by LB3:

userRepo.find({include: ['posts', 'passports']});

userRepo.find({
  include: [
    {relation: 'posts', scope: {where: {title: 'Post A'}}},
    'passports',
  ],
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer-experience Issues affecting ease of use and overall experience of LB users feature Repository Issues related to @loopback/repository package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants