Как иметь четное отношение в файле модели? - PullRequest
1 голос
/ 25 сентября 2019
asset shipment  identified by shipId{
o string shipId
o TemperatureThresholdEvent[] temperatureReading
}


event TemperatureThresholdEvent{
.....
} 

Я пытаюсь получить массив TemperatureThresholdEvent в активе отгрузки.Является ли объявление модели действительным?

1 Ответ

1 голос
/ 26 сентября 2019

Вы можете создать Массив события в файле модели.Он будет работать как единственное поле Array.

Пример:

namespace org.example.basic

asset SampleAsset identified by assetId {
  o String assetId
  --> SampleParticipant owner
  o String value
  o SampleEvent[] sampleEvent
}

Созданный актив содержит:

{
 "$class": "org.hyperledger.composer.system.AddAsset",
 "resources": [
  {
   "$class": "org.example.basic.SampleAsset",
   "assetId": "4467",
   "owner": "resource:org.example.basic.SampleParticipant#7145",
   "value": "Esse laboris quis consectetur.",
   "sampleEvent": [
    {
     "$class": "org.example.basic.SampleEvent",
     "asset": "resource:org.example.basic.SampleAsset#5945",
     "oldValue": "Proident aliqua id ex.",
     "newValue": "Esse ex aliqua exercitation sit.",
     "eventId": "6719",
     "timestamp": "2019-09-26T05:08:12.554Z"
    }
   ]
  }
 ],
 "targetRegistry": "resource:org.hyperledger.composer.system.AssetRegistry#org.example.basic.SampleAsset",
 "transactionId": "7ecd4664-c0d2-4b56-871e-6ff1ae9c4b56",
 "timestamp": "2019-09-26T05:08:20.448Z"
}
...