Fork me on GitHub
#vrac
<
2020-10-25
>
Vincent Cantin03:10:05

Lately, I took a break away from the project, now I am back at it.

Vincent Cantin05:10:40

Today I am working on modeling a query language which will be used between the Vrac clients and the Vrac servers.

Vincent Cantin05:10:36

I will call it VracQL (VQL in short), it naturally stands for Vrac’s Query Language

Vincent Cantin09:10:20

I finished to decide for the format:

; EQL
'{session [:session/title
           :session/description
           {:session/speakers [:speaker/name
                               :speaker/bio]}]}

; VQL
'[(:session/title session)
  (:session/description session)
  (for [speakers (:session/speakers session)]
    [(:speaker/name speakers)
     (:speaker/bio speakers)])]

;; VQL - same semantic as above
'(let [{:session/keys [title description speakers]} session]
   [title
    session
    (for [{:speaker/keys [name bio]} speakers]
      [name
       bio])])

; Returns values similarly to Clojure
["session title"
 "session description"
 [["name1"
   "bio1"]
  ["name2"
   "bio2"]]]

Vincent Cantin09:10:47

VracQL can include a directed graph of data computations, similarly to the Vrac templates.

; VQL - computed data
'[(- (:admin.money/spent global)
     (:admin.money/earned global))
  (count (:admin/users global))]

; VQL - let with computed data
'(let [{:admin/keys [users]
        :admin.money/keys [earning spending]} global
       benefit (- earning spending)
       nb-users (count users)]
   [benefit
    nb-users
    (/ benefit nb-users)])

Vincent Cantin09:10:38

VracQL is more verbose than EQL, but I like the fact that users won’t have to remember one more DSL syntax, as it is a subset of Clojure.

Vincent Cantin15:10:01

I pushed my VQL wip code at https://github.com/green-coder/vrac/blob/vracql/src/vrac/model/vql.cljc I am considering adding support for recursion in VQL later. Any suggestion about the syntax is welcome.