Expressions
KVM (Karma Virtual Machine) programs can be represented as data. The model for such data is called expression and found under tag _expression
.
Functions
Expressions are built by composing primitive functions. There are many functions available. Most functions are pure, some have side effects. These side effects correspond to data manipulation, i.e. persistent mutations to objects stored in a karma database.
Example
To illustrate, here's a simple karma progam:
Example:
Query:
e.all(e.tag(d.string("_tag")))
Result:
[
{
"model": [
"FCyAReCEenjhJqsb",
"CwdniKJtBtIlEYzI"
],
"tag": "_tag"
},
{
"model": [
"FCyAReCEenjhJqsb",
"GLEhvScBdSWYZBRW"
],
"tag": "_expression"
},
{
"model": [
"FCyAReCEenjhJqsb",
"FCyAReCEenjhJqsb"
],
"tag": "_model"
},
{
"model": [
"FCyAReCEenjhJqsb",
"ReUjWMdaHvGAJvzZ"
],
"tag": "_role"
},
{
"model": [
"FCyAReCEenjhJqsb",
"JPHNleKUAeTnXqlb"
],
"tag": "_user"
},
{
"model": [
"FCyAReCEenjhJqsb",
"sOolKDIdxgMuyQcg"
],
"tag": "_migration"
}
]
Notes:
yields a list of objects in the _tag
model.
Example:
Query:
e.tag(e.data(d.string("_tag")))
Result:
[
"fjxRgZyTyjEMruRg",
"BhngXKDJZDJdExxN"
]
Notes:
yields a reference to the _user
model