loopbackio / loopbackio/loopback-next

@loopback/cli: Controller rest generator with findOne method

Aperta
#5,531 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@mrnetforge ci sta già lavorando.

Dal 24/5/2020.

CLI developer-experience feature help wanted
Lingua principale
TypeScript
Stelle
5.1k
Fork
1.1k
Merge medio
2g 21h
PR unite (30g)
27

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.