您可以为嵌套对象创建单独的模型,
例如对于上述数据结构
你可以有类似的东西
export class CardAcceptor extends Address {
@property({
type: 'string',
required: true,
})
address: string;
@property({
type: 'string',
required: true,
})
idCode: string
@property({
type: 'string',
required: true,
})
name: string;
@property({
type: 'string',
required: true,
})
terminalId: string;
constructor(data?: Partial<CardAcceptor>) {
super(data);
}
}
export class Address extends Entity {
@property({
type: 'string',
required: true,
})
city: string;
@property({
type: 'string',
required: true,
})
country: string
@property({
type: 'string',
required: true,
})
county: string;
@property({
type: 'string',
required: true,
})
state: string;
@property({
type: 'boolean',
required: true,
})
zipCode: boolean;
constructor(data?: Partial<Address>) {
super(data);
}
}
export class BaseModel extends CardAcceptor {
@property.array(CardAcceptor)
cardAcceptor: CardAcceptor;
@property({
type: 'string',
required: true,
})
destinationCurrencyCode: string;
@property({
type: 'string',
required: true,
})
markUpRate: string
@property({
type: 'string',
required: true,
})
retrievalReferenceNumber: string;
@property({
type: 'string',
required: true,
})
sourceAmount: string;
@property({
type: 'boolean',
required: true,
})
sourceCurrencyCode: boolean;
@property({
type: 'array',
itemType: 'string',
default: [],
})
systemsTraceAuditNumber?: string[];
constructor(data?: Partial<Game>) {
super(data);
}
}
希望这会有所帮助。谢谢