Loopbackjs 如何使用cli b4 model命令处理环回4中的嵌套对象
我正在处理使用lb4需要建模的深层嵌套对象。我是否有可能获得有关此示例JSON代码的帮助Loopbackjs 如何使用cli b4 model命令处理环回4中的嵌套对象,loopbackjs,strongloop,loopback4,Loopbackjs,Strongloop,Loopback4,我正在处理使用lb4需要建模的深层嵌套对象。我是否有可能获得有关此示例JSON代码的帮助 { “持卡人”:{ “地址”:{ “城市”:“寄养城市”, “国家”:“RU”, “县”:“圣马特奥”, “州”:“CA”, “zipCode”:“94404” }, “idCode”:“ABCD1234ABCD123”, “名称”:“ABCD”, “terminalId”:“ABCD1234” }, “目的货币代码”:“840”, “markUpRate”:“1”, “retrievalReference
{
“持卡人”:{
“地址”:{
“城市”:“寄养城市”,
“国家”:“RU”,
“县”:“圣马特奥”,
“州”:“CA”,
“zipCode”:“94404”
},
“idCode”:“ABCD1234ABCD123”,
“名称”:“ABCD”,
“terminalId”:“ABCD1234”
},
“目的货币代码”:“840”,
“markUpRate”:“1”,
“retrievalReferenceNumber”:“201010101031”,
“sourceAmount”:“100”,
“sourceCurrencyCode”:“643”,
“systemsTraceAuditNumber”:“350421”
}
您可以为嵌套对象创建单独的模型
例如上述数据结构
你可以吃类似的东西
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);
}
}
导出类CardAcceptor扩展地址{
@财产({
键入:“字符串”,
要求:正确,
})
地址:字符串;
@财产({
键入:“字符串”,
要求:正确,
})
idCode:字符串
@财产({
键入:“字符串”,
要求:正确,
})
名称:字符串;
@财产({
键入:“字符串”,
要求:正确,
})
terminalId:字符串;
构造函数(数据?:部分){
超级(数据);
}
}
导出类地址扩展实体{
@财产({
键入:“字符串”,
要求:正确,
})
城市:字符串;
@财产({
键入:“字符串”,
要求:正确,
})
国家:字符串
@财产({
键入:“字符串”,
要求:正确,
})
县:串;
@财产({
键入:“字符串”,
要求:正确,
})
状态:字符串;
@财产({
类型:'布尔',
要求:正确,
})
zipCode:布尔;
构造函数(数据?:部分){
超级(数据);
}
}
导出类BaseModel扩展了CardAcceptor{
@数组(CardAcceptor)
cardAcceptor:cardAcceptor;
@财产({
键入:“字符串”,
要求:正确,
})
destinationCurrencyCode:字符串;
@财产({
键入:“字符串”,
要求:正确,
})
markUpRate:字符串
@财产({
键入:“字符串”,
要求:正确,
})
retrievalReferenceNumber:字符串;
@财产({
键入:“字符串”,
要求:正确,
})
sourceAmount:字符串;
@财产({
类型:'布尔',
要求:正确,
})
sourceCurrencyCode:布尔型;
@财产({
键入:“数组”,
itemType:'字符串',
默认值:[],
})
systemsTraceAuditNumber?:字符串[];
构造函数(数据?:部分){
超级(数据);
}
}
希望这能有所帮助。
谢谢
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);
}
}