18 lines
573 B
Fennel
18 lines
573 B
Fennel
(local Sqlog (require :sqlog))
|
|
(import-macros {: $ : query : specify} :sqlog.macros)
|
|
|
|
(local s (Sqlog))
|
|
(specify s
|
|
(table parent parent child)
|
|
(* [generation name (|| name " jr") 2] [parent name (|| name " jr")])
|
|
(* [generation name (|| name " iii") 3] [ancestor name (|| name " iii")])
|
|
(* [ancestor x y 2] [parent x y])
|
|
(* [ancestor x y (+ gen 1)] [parent x z] [ancestor z y gen])
|
|
[parent :bob "bob jr"]
|
|
[parent "bob jr" "bob iii"]
|
|
[parent :bob #(.. :fred :dy)]
|
|
[parent :fred :jim]
|
|
[parent :fred :betty])
|
|
(pp (query s [ancestor :bob descendant gen]))
|
|
|