Skip to content

Instantly share code, notes, and snippets.

View flyingsilverfin's full-sized avatar

Joshua Send flyingsilverfin

View GitHub Profile
flyingsilverfin / rules_in_typedb_match_user_access.tql
Last active December 8, 2022 10:48
Find users with access to resources
$x isa user; $r isa resource;
(accessor: $x, resource: $r) isa access, has permission $p;
flyingsilverfin / rules_in_typedb_permission_shortcut_rules.tql
Last active December 8, 2022 10:44
Rules in TypeDB blog: permission shortcut rules
rule permission-write-read:
when { $access isa write-access; }
then { $access has permission "read"; };
rule permission-read:
when { $access isa read-access; }
then { $access has permission "read"; };
rule permission-write:
when { $access isa write-access; }
flyingsilverfin / strong_typing_in_typedb_example_data.tql
Last active November 30, 2022 10:33
String Typing in TypeDB blog: example data
// entity with two attributes
$for-profit isa for-profit, has for-profit-id 99, has name "Google";
// entity with two attributes
$charity isa non-profit, has charity-id 10, has name "Greenpeace";
// entity with one explicitly declared attribute
$name isa name; $name = "Billy Joel";
flyingsilverfin / inference_in_typedb_social_network_schema.tql
Created November 29, 2022 11:44
Inference in TypeDB blog: social network schema
person sub entity,
plays friendship:friend,
plays following:follower,
plays family:member,
plays ownership:owner;
page sub entity,
plays following:followed,
plays ownership:owned,
plays parent-page:parent,
flyingsilverfin / strong_typing_in_typedb_match_inference_2.tql
Created November 28, 2022 17:04
Strong Typing in TypeDB blog: match inference 2
(buyer: $b, seller: $s) isa contract;
$b has charity-id $cid;
===== after type inference =====
$b may be [non-profit]
$s may be [for-profit, non-profit, person]
relation may be [resource-ownership]
$cid may be [charity-id]
flyingsilverfin / strong_typing_in_typedb_match_unsatisfiable.tql
Created November 28, 2022 17:03
Strong Typing in TypeQL blog: unsatisfiable match
match $p isa person, has org-id $id;
flyingsilverfin / strong_typing_in_typedb_match_org_contractors_inference.tql
Created November 28, 2022 17:02
Strong Typing in TypeDB blog: match contractors inference
$org isa organisation;
(buyer: $org, seller: $contracted) isa contract;
$contracted has name $name;
===== after type inference =====
$org may be [non-profit, for-profit]
$contracted may be [non-profit, for-profit, person]
$name may be [name]
flyingsilverfin / strong_typing_in_typedb_match_org_contractors.tql
Created November 28, 2022 17:01
Strong Typing in TypeDB blog: match organisation contractors
$org isa organisation;
(buyer: $org, seller: $contracted) isa contract;
$contracted has name $name;
flyingsilverfin / strong_typing_in_typedb_example_schema.tql
Last active November 28, 2022 16:49
Strong Typing in TypeDB blog: example schema
organisation sub entity,
owns name,
owns org-id,
plays contract:buyer,
plays contract:seller;
for-profit sub organisation,
owns for-profit-id as org-id;
non-profit sub organisation,
flyingsilverfin / strong_typing_in_typedb_lpg_in_typeql.tql
Created November 28, 2022 16:38
Implementing labelled property graphs in TypeQL
vertex sub entity,
owns label,
plays undirected-edge:end,
plays directed-edge:from,
plays directe-edge:to;
undirected-edge sub relation,
owns label,