-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repository): add belongsToUniquely sugar syntax method
- Loading branch information
Showing
20 changed files
with
185 additions
and
264 deletions.
There are no files selected for viewing
122 changes: 0 additions & 122 deletions
122
examples/todo-list/src/controllers/author.controller.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
examples/todo-list/src/controllers/todo-list-author.controller.ts
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
examples/todo-list/src/controllers/todo-list-image.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {TodoListRepository} from '../repositories'; | ||
import {repository} from '@loopback/repository'; | ||
import {param, post, requestBody, get} from '@loopback/rest'; | ||
import {TodoListImage} from '../models'; | ||
|
||
export class TodoListImageController { | ||
constructor( | ||
@repository(TodoListRepository) protected todoListRepo: TodoListRepository, | ||
) {} | ||
|
||
@post('/todo-lists/{id}/image', { | ||
responses: { | ||
'200': { | ||
description: 'create todoListImage model instance', | ||
content: {'application/json': {schema: {'x-ts-type': TodoListImage}}}, | ||
}, | ||
}, | ||
}) | ||
async create( | ||
@param.path.number('id') id: number, | ||
@requestBody() image: TodoListImage, | ||
): Promise<TodoListImage> { | ||
return await this.todoListRepo.image(id).create(image); | ||
} | ||
|
||
@get('/todo-lists/{id}/image', { | ||
responses: { | ||
'200': { | ||
description: 'The image belonging to the TodoList', | ||
content: {'application/json': {schema: {'x-ts-type': TodoListImage}}}, | ||
}, | ||
}, | ||
}) | ||
async find(@param.path.number('id') id: number): Promise<TodoListImage> { | ||
return await this.todoListRepo.image(id).get(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Entity, model, property, belongsToUniquely} from '@loopback/repository'; | ||
import {TodoList} from './todo-list.model'; | ||
|
||
@model() | ||
export class TodoListImage extends Entity { | ||
@belongsToUniquely(() => TodoList) | ||
todoListId?: number; | ||
|
||
@property({ | ||
required: true, | ||
}) | ||
// Ideally we would use Buffer type here, but | ||
// that is not supported yet. | ||
// see https://github.com/strongloop/loopback-next/issues/1742 | ||
value: string; | ||
|
||
constructor(data?: Partial<TodoListImage>) { | ||
super(data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
|
||
export * from './todo.repository'; | ||
export * from './todo-list.repository'; | ||
export * from './author.repository'; |
13 changes: 6 additions & 7 deletions
13
...ist/src/repositories/author.repository.ts → ...epositories/todo-list-image.repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.