A library for storing graph data in a Clojure map that automatically normalizes nested data and allows querying via EQL.
Create a new db with db
. db values are normal maps with a tabular structure.
Add new ones using add
.
Entities are identified by the first key with the name "id", e.g.
:person/id. Adding data about the same entity will merge them together in
order of addition. To replace an entity, dissoc
it first.
NOTE: Collections like vectors, sets and lists should not mix entities and non-entities. Collections are recursively walked to find entities.
Query them w/ EQL using pull
.
To get meta-information about what entities were added or queried, use the
add-report
and pull-report
functions.
A library for storing graph data in a Clojure map that automatically normalizes nested data and allows querying via EQL. Create a new db with `db`. db values are normal maps with a tabular structure. Add new ones using `add`. Entities are identified by the first key with the name "id", e.g. :person/id. Adding data about the same entity will merge them together in order of addition. To replace an entity, `dissoc` it first. NOTE: Collections like vectors, sets and lists should not mix entities and non-entities. Collections are recursively walked to find entities. Query them w/ EQL using `pull`. To get meta-information about what entities were added or queried, use the `add-report` and `pull-report` functions.
(add db data)
(add db data & more)
Takes a normalized map db
, and some new data
.
Returns a new map with the data normalized and merged into db
.
Takes a normalized map `db`, and some new `data`. Returns a new map with the data normalized and merged into `db`.
(add-report db data)
Takes a normalized map db
, and some new data
.
Returns a map containing keys:
:db - the data normalized and merged into db
.
:entities - a set of entities found in data
Takes a normalized map `db`, and some new `data`. Returns a map containing keys: :db - the data normalized and merged into `db`. :entities - a set of entities found in `data`
(data->ast data)
Like autonormal.core/data->query, but returns the AST.
Like autonormal.core/data->query, but returns the AST.
(data->query data)
Returns an EQL query that matches the shape of data
passed to it.
Useful when you have some data already and want to see what an EQL query that
returns that data would look like.
Returns an EQL query that matches the shape of `data` passed to it. Useful when you have some data already and want to see what an EQL query that returns that data would look like.
(db)
(db entities)
(db entities identify)
Takes an optional collection of entities
.
Returns a new map with the entities
normalized.
Takes an optional collection of `entities`. Returns a new map with the `entities` normalized.
(delete db lookup-ref)
Deletes an entity from the db, removing all references to it. A lookup-ref is a vector of [keyword id], e.g. [:person/id "a123"]
Deletes an entity from the db, removing all references to it. A lookup-ref is a vector of [keyword id], e.g. [:person/id "a123"]
(pull db query)
Executes an EQL query against a normalized map db
and returns the result.
Executes an EQL query against a normalized map `db` and returns the result.
(pull-report db query)
Executes an EQL query against a normalized map db
. Returns a map with the
following keys:
:data - the result of the query
:entities - a set of lookup refs that were visited during the query
Executes an EQL query against a normalized map `db`. Returns a map with the following keys: :data - the result of the query :entities - a set of lookup refs that were visited during the query
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close