Struct Variables

Unlike scalar values, you cannot define a struct variable in memory. The following is not allowed.

  let x Customer = {firstName: 'bob', lastName: 'smith', birthDate:'2021'} //not allowed!!

Instead, struct variables are created using queries (see …) that obtain values from the database.

 type Customer struct {
    firstName string
    lastName string
   } end

 insert Customer {firstName:'bob', lastName:'smith'}
 insert Customer {firstName:'sue', lastName:'foley'}

 let c = Customer[true] //query for all Customer objects

This code inserts two records into the database and then queries them back. The value of variable c will be a list of two Customer objects.

You can extract individual fields from c like this:

 let who = c[0].firstName //will equals 'bob'
 let names = c.firstName //will be a list of ['bob', 'sue']