Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 775 Bytes

builtins.md

File metadata and controls

31 lines (22 loc) · 775 Bytes

Enumerated Field ($enum)

Enumerated values are sort of like inlined $dictionaries. $enum(collection) picks a value from the given collection:

# declare a collection
let statuses = ["To do", "Doing", "Done!"]

entity Work {
  status: $enum(statuses) # randomly picks from statuses
}

generate() statements also yield collections of $ids from generated entities. This can be used in conjunction with $enum fields to define relationships:

entity CatalogItem {
  name: $str(),
  sku:  $int(1000, 3000)
}

# Assign the collection from generate() to a variable
let Catalog = generate(20, CatalogItem)

# each cart will have 1 - 5 CatalogItems as its contents
entity ShoppingCart {
  contents: $enum(Catalog)<1..5>
}