Remove rules that find and retract facts based upon ancestor hierarchy
Reduce schema definitions to facts that belong to the persistence layer only
Make default hierarchy for all facts #{:all :one-to-one}
Store fn created by util/make-ancestors-fn in state/ancestors-fn
Collapse Datomic's uniqueness distinctions into :unique and continue to perform upserts on unique attributes following research in #32
Add state/fact-index atom with e-a index for :one-to-one facts, a v index for :unique. E.g.:
:one-to-one -> e -> a -> fact
:unique -> a -> v -> fact
Support :one-to-many but do not track in fact index (doesn't seem necessary)
Add fact-index-path fn that uses state/ancestor-fn to determine a fact's location in the fact index according to its type
Add find-in-fact-index: If existing fact in index, replaces it and returns existing fact so it can be retracted. Else writes new fact to index and returns nil (no retraction)
All insert fns index the facts they receive as arguments and receive a list of facts to be retracted. Both are diffed using clojure.set/difference to avoid performance degradation when retracting many facts using Clara's retract.
All retract fns remove the facts they receive as arguments from fact-index
Added tests for new fns
Modified existing tests that were not concerned with adhering to :one-to-one or other schema distinctions to work as previously with added changes to insert/retract
#{:all :one-to-one}
util/make-ancestors-fn
instate/ancestors-fn
:unique
and continue to perform upserts on unique attributes following research in #32state/fact-index
atom with e-a index for:one-to-one
facts, a v index for:unique
. E.g.::one-to-many
but do not track in fact index (doesn't seem necessary)fact-index-path
fn that usesstate/ancestor-fn
to determine a fact's location in the fact index according to its typefind-in-fact-index
: If existing fact in index, replaces it and returns existing fact so it can be retracted. Else writes new fact to index and returns nil (no retraction)clojure.set/difference
to avoid performance degradation when retracting many facts using Clara'sretract
.fact-index