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

Improve Inclusion Resolver #3195

Closed
3 tasks
nabdelgadir opened this issue Jun 20, 2019 · 2 comments
Closed
3 tasks

Improve Inclusion Resolver #3195

nabdelgadir opened this issue Jun 20, 2019 · 2 comments
Labels
feature Relations Model relations (has many, etc.)

Comments

@nabdelgadir
Copy link
Contributor

Description / Steps to reproduce / Feature proposal

Currently, we have a temporary implementation for an inclusion resolver e.g. (in the find method in todo.repository.ts):

// poor-mans inclusion resolver, this should be handled by DefaultCrudRepo
// and use `inq` operator to fetch related todo-lists in fewer DB queries
// this is a temporary implementation
  if (include && include.length && include[0].relation === 'todoList') {
    await Promise.all(
      result.map(async r => {
        r.todoList = await this.todoList(r.id);
      }),
    );
  }

Related: #2633

Acceptance Criteria

  • Improve the implementation so that find methods fetch related instances relation models at a production-grade level.
    • This should be implemented in DefaultCrudRepository
    • Use inq operator to fetch the related model instance(s) in fewer DB queries

cc @bajtos

nabdelgadir added a commit that referenced this issue Jun 21, 2019
- Overwrote find and findById functions in TodoRepository, TodoListRepository, TodoListImage to include a hard-coded retrieval of related models. #3195 is for improvement of this
- Updated response schemas for controller methods find and findById to leverage getModelSchemaRef and includeRelations
- Updated TodoList tutorial

Co-authored-by: Miroslav Bajtoš <[email protected]>
nabdelgadir added a commit that referenced this issue Jun 21, 2019
- Overwrote find and findById functions in TodoRepository, TodoListRepository, TodoListImage to include a hard-coded retrieval of related models. #3195 is for improvement of this
- Updated response schemas for controller methods find and findById to leverage getModelSchemaRef and includeRelations
- Updated TodoList tutorial

Co-authored-by: Miroslav Bajtoš <[email protected]>
@bajtos
Copy link
Member

bajtos commented Jun 24, 2019

This story requires #2634 to be finished first.

@bajtos bajtos added the Relations Model relations (has many, etc.) label Jun 24, 2019
@bajtos
Copy link
Member

bajtos commented Jul 26, 2019

Closing in favor of #3450 and the issues it depends on.

@bajtos bajtos closed this as completed Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Relations Model relations (has many, etc.)
Projects
None yet
Development

No branches or pull requests

3 participants