我在超级分类账作曲家公司工作。在cto模型上,我定义了一个包含疫苗列表的资产儿童。这一资产的定义如下:
asset Child identified by childId {
o String childId
o String name
o String surname
o DateTime dateOfBirth
o Vaccin[] vaccins optional
--> Parent hasparent
--> Doctor hasdoctor
}asset defVaccin identified by vaccinId { o String vaccinId o String diseases o Integer timeFirst o Integer timeSecond optional o Integer timeThird optional o Integer timeFourth optional o Integer timeFifth optional }
为了在这个列表中创建/添加疫苗,我使用了一个事务“疫苗接种”,它在cto模型上定义如下:
transaction Vaccinate {
--> Child inchild
--> defVaccin aboutvaccin
o DateTime dateOfVaccin
}像这样出现在logic.js上
function vaccinate(vaccinate) {
var factory = getFactory();
var vaccin = factory.newConcept('vaccinspace', 'Vaccin', vaccinate.aboutvaccin.vaccinId); // create vaccin concept
// define value of concept's properties
vaccin.vaccinId = vaccinate.aboutvaccin.vaccinId;
vaccin.dateOfVaccin = vaccinate.dateOfVaccin;
// add this vaccine at the list of child's vaccines
vaccinate.inchild.addArrayValue("vaccins", vaccin)
return getAssetRegistry('vaccinspace.Child')
.then (function (assetRegistry) {
return assetRegistry.update(vaccinate.inchild); // update the list of child's vaccines
});
}这很好,我把所有的疫苗都列在我的清单上了。但如果我修改我的孩子或我的疫苗(只需做一个修改孩子的名字为例),我有一个空的列表之后。
有人知道为什么我的信息会被从我的名单中删除吗?我怎么才能改变这个?
发布于 2018-06-08 16:45:58
试一试
// add this vaccine to the list of child's vaccines array of concepts
vaccinate.inchild.vaccins.push(vaccin);而不是
// add this vaccine at the list of child's vaccines
vaccinate.inchild.addArrayValue("vaccins", vaccin);https://stackoverflow.com/questions/50701409
复制相似问题