【问题标题】:Should NOT have additional properties ( Loopback, MongoDB)不应该有额外的属性(环回,MongoDB)
【发布时间】:2021-12-11 16:08:57
【问题描述】:

在我的模型中,我有必需的属性,但是当我从前面提出请求时,我收到一个错误,例如“不应该有其他属性”的必填字段。你能帮帮我吗?

型号:

import {Entity, model, property} from '@loopback/repository';

@model()
export class InternalProjectServiceType extends Entity {
  @property({
    type: 'string',
    id: true,
    generated: true,
  })
  id?: string;

  @property({
    type: 'string',
    required: true,
  })
  internalProjectId: string;

  @property({
    type: 'string',
  })
  serviceTypeId?: string;

  constructor(data?: Partial<InternalProjectServiceType>) {
    super(data);
  }
}

export interface InternalProjectServiceTypeRelations {
  // describe navigational properties here
}

export type InternalProjectServiceTypeWithRelations = InternalProjectServiceType & InternalProjectServiceTypeRelations;

【问题讨论】:

    标签: node.js mongodb loopback


    【解决方案1】:

    我有同样的问题。我使用 Angular 和 nodejs 然后回送我的 api。我注意到那个案子很重要。例如,在您的情况下 internalProjectId: string; INTERNALPROJECTID:字符串;是不同的。在您的逻辑中,您应该确保您发布的帖子与您的环回模型相同。如果在您的逻辑中您发布为 internalProjectId 并且在您的环回模型中您将 INTERNALPROJECTID 声明为属性,您将收到错误 "Should NOT have additional properties" 值得注意的是,我使用的是 Loopback。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-01
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 2022-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多