object
Parent of all object types. An object is a singleton data structure that resides in the SQL database.
Objects are much like entities, with the following restrictions:
only a single instance is allowed for each definition
all object attributes must have default values
object values cannot be created or deleted from code (they are automatically created during blockchain initialization)
Example definition:
object state {
mutable x: integer = 0;
mutable s: text = 'n/a';
}
Content copied to clipboard
Object attributes are accessed directly:
print(state.x);
print(state.s);
Content copied to clipboard
Object values can be modified directly, or with an update
statement:
// Direct modification
state.x += 10;
state.s = 'Updated';
// Modification via update statement
update state ( x += 5, s = 'Updated' );
Content copied to clipboard
Since
0.7.0