loopbackio / loopbackio/loopback-next
@loopback/cli: Controller rest generator with findOne method
@mrnetforge ya está trabajando en esto.
Desde el 24/5/2020.
- Lenguaje dominante
- TypeScript
- Estrellas
- 5.1k
- Forks
- 1.1k
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 27
Descripción
## Suggestion
Currently, cli generator controller doesn't provide findOne method inside file. Method findOne exists in repository that is associated with controller, so i think i should be generated. For now i must manually add this method to all my controllers
```ts
@get('/config/findOne', {
responses: {
'200': {
description: 'Config model instance',
content: {
'application/json': {
schema: getModelSchemaRef(Config, { includeRelations: true }),
},
},
},
},
})
async findOne(
@param.filter(Config) filter?: Filter,
): Promise {
return this.configRepository.findOne(filter);
}
```
## Use Cases
`lb4 controller` with REST option should create findOne inside controller (example above)
## Examples
In my scenario i have model that i need to find not by id but based on custom filter. It would be much easier when this method can be created out of the box.
## Acceptance criteria
TBD - will be filled by the team.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.