不应该有额外的属性(环回,MongoDB)



在我的模型中,我需要属性,但当我从前面请求时,我得到一个错误,如"不应该有额外的属性";为所需字段。你能帮我吗?

模型:

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;

我也有同样的问题。我使用Angular和nodejs,然后为我的api环回。我注意到这个案子很重要。例如internalProjectId:字符串;和INTERNALPROJECTID:字符串;是不同的。在您的逻辑中,您应该确保您正在对与您的环回模型相同的情况进行post。如果在您的逻辑中,您发布为internalProjectId在你的环回模型中你声明了INTERNALPROJECTID作为一个属性,你会得到错误"不应该有额外的属性">值得注意的是,我使用环回。

最新更新