loopbackio / loopbackio/loopback-next

Loopback 4: Exclude issue in hasone relations

Abierto
#7,517 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

feature help wanted OpenAPI
Lenguaje dominante
TypeScript
Estrellas
5.1k
Forks
1.1k
Merge medio
2 d 21 h
PR fusionados (30 d)
27

Descripción

Hello all,

I have looked for a solution to that, but I see nothing in the documentation and in the forums. I start to think that it is not possible to do, or that it is some kind of issue.

In a schema, It is possible to exclude a field how comes from a @hasone relation?

Captura de pantalla 2021-05-29 a las 10 00 18

I have tried several things. The more weird is that if in the exclude you indicate a property who appears in the model A and in the hasOne relation model, in the schema, for both models, the property is excluded. :

 @patch('/user/{id}', {
    responses: {
      '204': {
        description: 'Update all the information related with the user',
      },
    },
  })
  @authenticate('jwt', { required: [PermissionKey.UpdateOwnUser] })
  async updateById(
    @param.path.string('id') id: string,
    @requestBody({
      content: {
        'application/json': {
          schema: getModelSchemaRef(UserFeatures, {
            includeRelations: true,
            exclude: ['idUser', 'stripeCustomerId', 'userIAM.permissions'],
          }),


        },
      },
    })

The problem is that the exclude doesnt´work for the hasOne relation: exclude: ['idUser', 'stripeCustomerId'] --> OK exclude: ['permissions'] --> Fails

Any idea of how to exclude a field of the "hasOne Relation model"?

Thanks in advance

Best

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.

Línea de trabajo

Comienza en getModelSchemaRef y en el esquema de @requestBody mostrado en el issue, centrándote en cómo se interpretan includeRelations y exclude para las relaciones hasOne. Reproduce el ejemplo con exclude: ['permissions']; estará terminado cuando se excluya el campo de la relación anidada sin cambiar las exclusiones existentes de nivel superior.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
api
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.