我需要模型中的一些属性,例如字符串数组以及与其他模型的直接关系
答案 0 :(得分:1)
在convector教程中,使用
扩展Person模型。export class Attribute extends ConvectorModel<Attribute>{
...ommited
@Validate(yup.array(Attribute.schema()))
public attributes: Array<Attribute>;
@Required()
@Default(['USER'])
@Validate(yup.array().of(yup.string))
public roles: Array<String>;
@Required()
@Validate(Participant.schema())
public participant: FlatConvectorModel<Participant>;
}
部署链码并使用
进行调用# send USER,ADMIN role
npx hurl invoke person person_create "{\"id\":\"1-100-103\",\"firstname\":\"Pete\",\"lastname\":\"Doe\",\"username\":\"pete\",\"password\":\"12345678\",\"email\":\"pete.doe@example.com\",\"roles\":[\"USER\", \"ADMIN\"]}" -u admin
# test default role (omiting role)
$ npx hurl invoke person person_create "{\"id\":\"1-100-103\",\"firstname\":\"Pete\",\"lastname\":\"Doe\",\"username\":\"pete\",\"password\":\"12345678\",\"email\":\"pete.doe@example.com\"}" -u admin
未转义的数据
{
"id": "1-100-103",
"firstname": "Pete",
"lastname": "Doe",
"username": "pete",
"password": "12345678",
"email": "pete.doe@example.com",
"roles": [
"USER",
"ADMIN"
]
}
感谢沃尔特和迭戈
完成
谢谢