2017-06-22 59 views
0
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更新業務網絡後,有沒有辦法獲取舊資產數據?

回答

0

您通過對模型進行不兼容的更改來打破模型兼容性。舊的實例不再符合你的模型,不能被反序列化。

您應該更新模型並使新的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

這是一個更普遍的問題。請作爲單獨的問題發佈。謝謝。 –