loopbackio / loopbackio/loopback-next
@loopback/cli: Controller rest generator with findOne method
@mrnetforge y travaille déjà.
Depuis le 24/5/2020.
- Langage dominant
- TypeScript
- Étoiles
- 5.1k
- Forks
- 1.1k
- Merge moyen
- 2 j 21 h
- PR mergées (30 j)
- 27
Description
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
@get('/config/findOne', {
responses: {
'200': {
description: 'Config model instance',
content: {
'application/json': {
schema: getModelSchemaRef(Config, { includeRelations: true }),
},
},
},
},
})
async findOne(
@param.filter(Config) filter?: Filter<Config>,
): Promise<ConfigWithRelations | null> {
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Évaluation
Cette issue n'a pas encore été évaluée.