loopbackio / loopbackio/loopback-next

@loopback/cli: Controller rest generator with findOne method

Abierto
#5,531 4 comentarios 0 reacciones 1 asignado Ver en GitHub

@mrnetforge ya está trabajando en esto.

Desde el 24/5/2020.

CLI developer-experience feature help wanted
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

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.