pull
and
pull-report
.pyramid.core/identify
function which takes a DB and entity map and returns the lookup ID of the map if it were added to the DB.Visitor pattern: you can now annotate parts of an EQL query with
{:visitor (fn visit [db data] ,,,)}
metadata, which will replace the location
with the return value of the visit
function in the final result of the pull
or pull-report
call.
It is similar to doing a postwalk on the results of pull
or pull-report
, but
is done in the same pass as pulling data out of the DB - so less traversals - and
annotated directly on the query.
See pull_test.cljc for example usage.
merge-entity
in babashkaThis update includes a significant rewrite of the algorithm which traverses & pulls data out of the db based on an EQL query. It has a minor if any performance impact, but allows working with arbitrarily nested data.
IPullable
to resolve entities, allowing
pyramid to query arbitrary data stores using EQL.IQueryable
to get all entities from an
object, allowing pyramid to query arbitraty data stores in memory.pull-report
now returns an :indices
key with a set of top-level indices
that are used in the query.add-report
now returns an :indices
key with a set of top-level indices
that are modified through adding the data to the dbThis update includes a significant rewrite of the normalization algorithm which in the real world results in a 50% reduction in time spent normalization and also supports arbitrary levels of nesting (up to computer memory limits).
Renamed to pyramid. Experimental datalog-like query engine. Internal refactor to use zippers.
In 1.2.0, we try to figure out how to identify a map by running a fn on each key without context. This precludes more complex logic, such as preferring one ID over another or using a composite of multiple keys to produce an ident.
Now, when you create a new db value, the optional second argument should be a function that takes the entire map as a value and returns either an ident (a tuple [key val] that uniquely identifies the entity in your system) or nil.
Additionally, a new namespace autonormal.ident
is available for composing
functions for identifying entities.
(require '[autonormal.core :as a]
'[autonormal.ident :as ident])
;; creates a new db that will use `person/id` and `:food/name`
;; to identify entities
(a/db
[]
(fn [entity]
;; first, check for :person/id
(if-let [person-id (:person/id entity)]
[:person/id person-id]
;; else, check for :food/name. return nil otherwise
(when-let [food-name (:food/name entity)]
[:food/name food-name]))))
;; autonormal.ident/by is a helper to compose functions that take an entity
;; and return either an ident or nil
(a/db [] (ident/by
(fn [entity]
(when-let [person-id (:person/id entity)]
[:person/id person-id]))
(fn [entity]
(when-let [food-name (:food/name entity)]
[:food/name food-name]))))
;; autonormal.ident/by-keys is a helper that handles the specific case of
;; composing keys
(a/db [] (ident/by-keys :person/id :food/name))
db
now takes a second argument, identify
, which is a function used to determine whether a key is
used to identify the entity or not:autonormal.core/not-found
values were still present in union entries, are now filtered out appropriatelyThis is a minor bump to better reflect changes made in 1.0.3 and 1.0.2.
delete
, which dissocs an entity from the db and removes all references to itadd-report
, which returns a map with keys :db
, containing the updated map,
and :entities
, which contains the set of lookup refs modified
pull-report
, which returns a map with keys :data
, containing the result of
the EQL query, and :entities
, which contains the set of lookup refs
queried in :data
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close