https://github.com/functionalfoundry/query-engine
Engine to run Om Next queries against different data layers
https://github.com/functionalfoundry/query-engine
Last synced: 6 months ago
JSON representation
Engine to run Om Next queries against different data layers
- Host: GitHub
- URL: https://github.com/functionalfoundry/query-engine
- Owner: functionalfoundry
- License: mit
- Created: 2016-09-29T09:19:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-12T22:51:26.000Z (over 8 years ago)
- Last Synced: 2025-07-04T22:50:56.858Z (12 months ago)
- Language: Clojure
- Homepage: http://functionalfoundry.github.io/query-engine
- Size: 227 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# workflo/query-engine
[](https://clojars.org/workflo/query-engine)
[](https://travis-ci.org/functionalfoundry/query-engine)
[API docs](http://functionalfoundry.github.io/query-engine/)
The `workflo/query-engine` allows to execute [Om Next](https://github.com/omcljs/om)
queries against different data layers, including:
* [entitydb](https://github.com/functionalfoundry/entitydb)
* [DataScript](https://github.com/tonsky/datascript)
* [Datomic](http://www.datomic.com/)
## Usage (DataScript)
```clojure
(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"}}
```
## Testing
1. Install [boot](http://boot-clj.com/)
2. Clone this repository
3. Run the tests:
- `boot test` to run tests once
- `boot watch test` to run tests continuously on changes
## License
`workflo/query-engine` is copyright (C) 2016-2017 Workflo, Inc.
Licensed under the MIT License.
For more information [see the LICENSE file](LICENSE).