The workflo/query-engine
allows to execute Om Next
queries against different data layers, including:
(require '[clojure.spec.alpha :as s]
'[workflo.macros.entity :refer [defentity registered-entities]]
'[workflo.macros.entity.datascript :refer [entity-schema]]
'[workflo.macros.specs.types :as types]
'[workflo.query-engine.core :as query-engine]
'[workflo.query-engine.data-layer.datascript-no-authorization :as dl])
;; Define a user entity with workflo/macros
(s/def :user/name ::types/string)
(s/def :user/email ::types/string)
(defentity user
(spec
(s/keys :req [:db/id
:user/name
:user/email])))
;; Create a DataScript schema
(def schema (->> (registered-entities)
(vals)
(map entity-schema)
(apply merge)))
;; Create a DataScript database
(def conn (ds/create-conn schema)
;; ... Populate the database with users ...
;; Run a query against the database, fetch all users
;; with their IDs and names
(query-engine/query [{:users [:db/id :user/name]}]
(dl/data-layer)
{:db @conn})
;; -> #{{:db/id 1 :user/name "John"}
;; {:db/id 2 :usder/name "Linda"}}
- Install boot
- Clone this repository
- Run the tests:
boot test
to run tests onceboot watch test
to run tests continuously on changes
workflo/query-engine
is copyright (C) 2016-2017 Workflo, Inc.
Licensed under the MIT License.
For more information see the LICENSE file.