Patterns overview
What is a pattern?
A pattern is a set of declarative constraints. TypeQL uses patterns in its queries and clauses.
-
In data queries, patterns are used to specify constraints on concepts to be retrieved or processed.
-
In schema queries, we use schema-specific patterns without any variables to define or undefine type definitions.
Patterns are built from statements using pattern operations.
Composing patterns
You can combine two patterns by joining their statements together in a new pattern. All semicolon-separated statements are combined with an implicit conjunction. That makes the order of statements irrelevant. Hence, it’s easy to change the results by adding new constraints to the pattern.
For example, in the following pattern
the $u
variable is specified to be a user with a full-name
attribute, which value is equal to Kevin Morrison
,
the $f
variable is a file with a path
equal to zlckt.ts
.
Finally, there are two relations that specify a connection between the $u
and the $f
.
$u isa user, has full-name "Kevin Morrison";
$f isa file, has path "zlckt.ts";
$acc ($f, $act) isa access;
$per ($u, $acc) isa permission;