hyperledger-composer - 看跌期权后资产中的信息消失
问题描述
我在超级账本作曲家工作。在模型 cto 上,我定义了一个包含疫苗列表的资产 Child。该资产定义为:
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
}
- 一个资产 defVaccin,其中包含一些疫苗的定义。疫苗定义为:
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
}
为了在这个列表中创建/添加疫苗,我使用了一个事务“vaccinate”,它在模型 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
});
}
这很好用,我的清单里有我所有的疫苗。但是如果我修改了我的孩子或我的疫苗(例如,只是做一个改变孩子的名字),我之后会有一个空列表。
有人知道为什么我的信息会从我的列表中“消失”吗?我怎样才能改变这个?
解决方案
尝试
// 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);
推荐阅读
- javascript - Bootstrap 和 JS - 如何在有限的情况下适应高数字空间
- bash - 如何在bash脚本中将一个文件夹中的所有tif文件转换为pdf并保存在另一个位置而不循环?
- javascript - 如何将所有子元素包装在一个类中?
- android - 文本大小增量在 Android 中不起作用
- node.js - 运行 npm install @angular/pwa 时出现错误 Rolling back node-pre-gyp@0.14.0 failed
- mongodb - 猫鼬当我使用更新时,它不会更新状态为 200(成功)的任何内容
- php - GAE - 实例似乎死亡并返回 502,而不是优雅地部署
- deployment - 在 Azure DevOps 部署后批准邮件中获取更多详细信息
- javascript - 使用 useState React Native 编辑数组
- java - 如何在我的机器上的 docker 守护进程和 Jenkins 之间建立连接以执行 docker 命令?