Statements
This reference covers the usage of statements in TypeQL.
A TypeQL statement is a building block of a TypeQL pattern. Statements in TypeQL always end with a semicolon.
Simple statements
A simple statement is the smallest pattern that can be in a TypeQL query.
Most simple statements have two or three parts: <PREDICATE> <SUBJECT>, <SUBJECT> <PREDICATE> or <SUBJECT> <PREDICATE> <OBJECT>, where <PREDICATE> is a TypeQL keyword.
However, there can be other more complex statements like let … in statement.
Composite statements
Multiple simple statements with the same subject can be combined into a composite statement. A composite statement starts with a single subject, and multiple comma-separated simple statements with subject omitted.
See an example
define
entity user sub profile,
owns phone,
owns karma;
The above example combines simple entity, sub, owns, and plays statements to the same result without repeating the subject:
define
entity user;
user sub profile;
user owns phone;
user owns karma;
The comma separation is required before a <PREDICATE> if its <SUBJECT> already has another <PREDICATE> on its right side.
|
The first predicates in the example above do not require a comma. However, every simple statement can be separated by commas if preferred. |