旧资产模型:
由order_Id标识的资产PurchaseOrder {
o String order_Id
o String asset_ID
o String asset_Name
o String order_Desc
o String order_Quantity
o String supplier_Id}
将资产模型更新为:
由order_Id标识的资产PurchaseOrder {
o String order_Id
o String asset_ID
o String asset_Name
o String order_Desc
o String order_Quantity
o String supplier_Id
o String supplier_Name}
然后使用composer-cli命令更新业务网络。
现在,当我尝试使用composer-rest-server API获取(获取)旧资产数据时,我得到了以下错误:
{
“错误”:{
"statusCode": 500,
"name": "Error",
"message": "Error: Instance org.suppchain.PurchaseOrder#o2 missing required field supplier_Name",
"code": 2,
"metadata": {
"_internal_repr": {}
},
"stack": "Error: Error: Instance org.suppchain.PurchaseOrder#o2 missing required field supplier_Name\n at /home/ubuntu/.nvm/versions/node/v6.9.5/lib/node_modules/composer-rest-server/node_modules/fabric-client/node_modules/grpc/src/node/src/client.js:434:17"}
}
如果我们正在更新商业网络,我认为,我们应该能够获取旧数据。有没有办法在使用composer更新业务网络后获取旧资产数据?
发布于 2017-06-22 16:12:43
您通过对模型进行不兼容的更改破坏了模型兼容性。旧的实例不再符合您的模型,并且无法反序列化。
您应该更新您的模型,并使新的supplier_Name属性成为可选的或为其提供默认值。
例如:
asset PurchaseOrder identified by order_Id {
o String order_Id
o String asset_ID
o String asset_Name
o String order_Desc
o String order_Quantity
o String supplier_Id
o String supplier_Name optional
}或者:
asset PurchaseOrder identified by order_Id {
o String order_Id
o String asset_ID
o String asset_Name
o String order_Desc
o String order_Quantity
o String supplier_Id
o String supplier_Name default="UNKNOWN"
}https://stackoverflow.com/questions/44691834
复制相似问题