Skip to content

Commit

Permalink
fixup! apply most feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nabdelgadir committed Jun 21, 2019
1 parent 3edb06b commit 0f98b97
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 20 deletions.
28 changes: 20 additions & 8 deletions docs/site/tutorials/todo-list/todo-list-tutorial-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ async find(
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};
const result = await super.find(filter, options);
// poor-mans inclusion resolver, this should be handled by DefaultCrudRepo
// and use `inq` operator to fetch related todos in fewer DB queries
// this is a temporary implementation, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todos') {
await Promise.all(
result.map(async r => {
Expand All @@ -133,10 +135,14 @@ async findById(
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};
const result = await super.findById(id, filter, options);
// poor-mans inclusion resolver, this should be handled by DefaultCrudRepo
// and use `inq` operator to fetch related todos in fewer DB queries
// this is a temporary implementation, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todos') {
result.todos = await this.todos(result.id).find();
}
Expand All @@ -151,12 +157,12 @@ your related `Todo`s, for example:
```json
{
"id": 2,
"title": "daily routine of POTUS",
"title": "My daily chores",
"todos": [
{
"id": 3,
"title": "terrorize senate",
"desc": "Tell them they're getting a budget cut.",
"title": "play space invaders",
"desc": "Become the very best!",
"todoListId": 2
}
]
Expand All @@ -175,12 +181,14 @@ async find(
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};

const result = await super.find(filter, options);

// poor-mans inclusion resolver, this should be handled by DefaultCrudRepo
// and use `inq` operator to fetch related todo-lists in fewer DB queries
// and use `inq` operator to fetch related todo-lists in fewer DB queries
// this is a temporary implementation, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todoList') {
await Promise.all(
result.map(async r => {
Expand All @@ -200,10 +208,14 @@ async findById(
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};

const result = await super.findById(id, filter, options);

// 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, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todoList') {
result.todoList = await this.todoList(result.id);
}
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
givenTodoListRepositories,
} from '../helpers';

describe('TodoListApplication', () => {
describe('TodoListImageRepository', () => {
let app: TodoListApplication;
let todoListImageRepo: TodoListImageRepository;
let todoListRepo: TodoListRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
givenTodoRepositories,
} from '../helpers';

describe('TodoListApplication', () => {
describe('TodoListRepository', () => {
let app: TodoListApplication;
let todoRepo: TodoRepository;
let todoListRepo: TodoListRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
givenTodoRepositories,
} from '../helpers';

describe('TodoListApplication', () => {
describe('TodoRepository', () => {
let app: TodoListApplication;
let todoRepo: TodoRepository;
let todoListRepo: TodoListRepository;
Expand Down
13 changes: 10 additions & 3 deletions examples/todo-list/src/repositories/todo-list-image.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ export class TodoListImageRepository extends DefaultCrudRepository<
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};

const result = await super.find(filter, options);

// this is a temporary implementation, please see https://github.com/strongloop/loopback-next/issues/3195
// 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, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todoList') {
await Promise.all(
result.map(async r => {
Expand All @@ -72,10 +75,14 @@ export class TodoListImageRepository extends DefaultCrudRepository<
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};

const result = await super.findById(id, filter, options);

// 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, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todoList') {
result.todoList = await this.todoList(result.id);
}
Expand Down
13 changes: 10 additions & 3 deletions examples/todo-list/src/repositories/todo-list.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ export class TodoListRepository extends DefaultCrudRepository<
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};
const result = await super.find(filter, options);

// this is a temporary implementation, please see https://github.com/strongloop/loopback-next/issues/3195
// poor-mans inclusion resolver, this should be handled by DefaultCrudRepo
// and use `inq` operator to fetch related todos in fewer DB queries
// this is a temporary implementation, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todos') {
await Promise.all(
result.map(async r => {
Expand All @@ -89,10 +92,14 @@ export class TodoListRepository extends DefaultCrudRepository<
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};

const result = await super.findById(id, filter, options);

// poor-mans inclusion resolver, this should be handled by DefaultCrudRepo
// and use `inq` operator to fetch related todos in fewer DB queries
// this is a temporary implementation, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todos') {
result.todos = await this.todos(result.id).find();
}
Expand Down
13 changes: 10 additions & 3 deletions examples/todo-list/src/repositories/todo.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ export class TodoRepository extends DefaultCrudRepository<
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};

const result = await super.find(filter, options);

// this is a temporary implementation, please see https://github.com/strongloop/loopback-next/issues/3195
// 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, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todoList') {
await Promise.all(
result.map(async r => {
Expand All @@ -69,10 +72,14 @@ export class TodoRepository extends DefaultCrudRepository<
// Prevent juggler for applying "include" filter
// Juggler is not aware of LB4 relations
const include = filter && filter.include;
filter = filter && Object.assign(filter, {include: undefined});
filter = {...filter, include: undefined};

const result = await super.findById(id, filter, options);

// 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, please see
// https://github.com/strongloop/loopback-next/issues/3195
if (include && include.length && include[0].relation === 'todoList') {
result.todoList = await this.todoList(result.id);
}
Expand Down

0 comments on commit 0f98b97

Please sign in to comment.