...

/

Enumerations and Model Classes in Model Code

Enumerations and Model Classes in Model Code

Let’s take a look at how the model class is coded.

Code the enumerations

Enumerations are coded in the following way with the help of the Enumeration meta-class:

Press + to interact
var PublicationFormEL = new Enumeration(
["hardcover", "paperback", "ePub", "PDF"]);
var BookCategoryEL = new Enumeration(
["novel", "biography", "textbook", "other"]);
var LanguageEL = new Enumeration({ "en": "English", "de": "German", "fr": "French", "es": "Spanish" });

Notice that LanguageEL defines a code list enumeration, while PublicationFormEL defines a simple enumeration.

Code the model class as JS class

It’s a good idea to ...