Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

den1k/transactable entity #59

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/datalevin/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ backward references).
before) are printed. See [[touch]]."}
entity de/entity)

(def add de/add)
(def retract de/retract)


(def ^{:arglists '([db eid])
:doc "Given lookup ref `[unique-attr value]`, returns numberic entity id.
Expand Down
8 changes: 8 additions & 0 deletions src/datalevin/db.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@
:db.fn/retractEntity
:db/retractEntity})

;; HACK to avoid circular dependency
(def de-entity? (delay (resolve 'datalevin.impl.entity/entity?)))
(def de-entity->txs (delay (resolve 'datalevin.impl.entity/->txs)))

(defn transact-tx-data [initial-report initial-es]
(when-not (or (nil? initial-es)
(sequential? initial-es))
Expand All @@ -708,6 +712,10 @@
(nil? entity)
(recur report entities)

(@de-entity? entity)
(recur report
(into entities (reverse (@de-entity->txs entity))))

(map? entity)
(let [old-eid (:db/id entity)]
(cond+
Expand Down
Loading