How To Create Enumerated Types In Your Hyperledger Composer Model File (.cto)
#1
This will be a continuation from this tutorial. The model file we're starting with can be downloaded from here.

In this tutorial I will be showing you how to create new types in your model files via enumerations. This is a simple process and will be a fairly short how to.

Step 1: Open The Model File
Open the downloaded model file with your preferred text editor.
[Image: attachment.php?aid=34]

Step 2: Add "enum"
Now at the end of our model file add "enum" and the name of our new type as shown below.
[Image: attachment.php?aid=35]

Step 3: Add our options
For our new "Beds" type, we will need to distinguish the rooms by "SINGLE", "DOUBLE", and "TRIPLE" as shown below.
[Image: attachment.php?aid=36]

Step 4: Add our new type to our asset
I have now added our new type to our asset. As you can see, I also set a default, which is a single-bed room.
[Image: attachment.php?aid=37]

Congratulations! You have now added in your very own enumeration.


Attached Files Thumbnail(s)
               
Reply