Officially out now: The TypeDB 3.0 Roadmap

value assignment

Value assignment doesn’t use any specific keyword, but it assigns a value to a concept variable that represents an attribute.

Syntax

The syntax of a value assignment statement includes:

  • concept variable

  • value

Syntax
<concept-variable> <value>;

Behavior

TypeQL value assignment statements can be used only in a match clause or rule condition.

Since only attributes can have a value, value assignment syntax implicitly bounds the concept variable to the attribute type. You can specify the type of the concept variable by bounding it explicitly with an isa statement.

Usage in a match pattern

For this example, use a database with the IAM schema and sample data loaded.

For example, let’s find all attributes of any type in a database with the value equal to the Kevin Morrison string:

Value assignment query example
match
$a "Kevin Morrison";
fetch $a;
See example output
Output example
{ "a": { "value": "Kevin Morrison", "type": { "label": "full-name", "root": "attribute", "value_type": "string" } } }

Usage in an insert pattern

For this example, use a database with the IAM schema and sample data loaded.

To explicitly insert an attribute, use a value assignment to set its value, and an isa statement to set its type:

Inserting attribute example
insert
$a "Bob" isa full-name;

Learn more

Learn more about type statement in TypeQL.

Learn about types in TypeQL.