得到错误,而使用作曲家

问题描述:

updateing业务网络后获取旧资产数据

旧资产模型:得到错误,而使用作曲家

:通过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 

}

最新的资产模型确定

资产的PurchaseOrder

资产PurchaseOrder由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 

}

然后使用composer-cli命令更新业务网络。

现在,当我试图获取(GET)采用作曲家休息服务器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更新业务网络后,有没有办法获取旧资产数据?

您通过对模型进行不兼容的更改来打破模型兼容性。旧的实例不再符合你的模型,不能被反序列化。

您应该更新模型并使新的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" 
} 
+0

感谢丹, 你能分享而不会破坏兼容性更新业务网络的指引? 如何使属性可选? –

+0

这是一个更普遍的问题。请作为单独的问题发布。谢谢。 –