使用 Comator 更新业务网络后获取旧资产数据时出错



旧资产模型:

资产采购订单由 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

}

资产模型更新为:

资产采购订单由 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

}

然后使用作曲家-CLI 命令更新业务网络。

现在,当我尝试使用作曲家-休息-服务器 API 获取(GET)旧资产数据时,出现以下错误:

{

"错误":{

"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_Namen    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"
}

最新更新