Officially out now: The TypeDB 3.0 Roadmap >>

Conjunction

A conjunction of patterns requires all its patterns to be true simultaneously. A conjunction is itself a pattern.

Syntax

There is no specific syntax to apply conjunctions: conjunctions are applied implicitly to all patterns delineated by a semicolon ;. A conjunction of two or more patterns is of the form

Syntax
<pattern>; <pattern>; [ <pattern>; ... ]

where each <pattern> is any valid pattern and we added ; to emphasize that patterns always end with ;. Note, each <pattern> itself may be a conjunction of smaller patterns or individual statements: see patterns for more information.

Behavior

Conjunction is used in all TypeQL patterns by default: it is implicitly applied between all statements separated with a semicolon.

All patterns in a conjunction must be true for the conjunction itself to be true. Thus, if any statement in a conjunction is false, then the whole pattern is false.

The ordering of statements in a conjunction is irrelevant, as every statement is equaly important for the whole pattern.

Usage in a match clause

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

Let’s fetch a path attribute for every file that a user with full-name "Kevin Morrison" has a permission to modify. There are multiple statements we need to combine with a conjunction for them all to be matched by every solution:

Conjunction example
match
$user isa user, has full-name 'Kevin Morrison';
($user, $access) isa permission;
$obj isa object, has path $path;
$access($obj, $act) isa access;
$act isa action, has name 'modify_file';
fetch $path;

In the above example, all statements in a match clause must be True for the solution to be found.

See example output
Output example (partial)
{ "path": { "value": "iopvu.java", "type": { "label": "path", "root": "attribute", "value_type": "string" } } }
{ "path": { "value": "README.md", "type": { "label": "path", "root": "attribute", "value_type": "string" } } }
{ "path": { "value": "budget_2021-08-01.xlsx", "type": { "label": "path", "root": "attribute", "value_type": "string" } } }

Learn more

Learn more about disjunction in TypeQL.

Learn more about negation in TypeQL.

Learn more about statements in TypeQL patterns.