clojure - Append new data to entity in Datomic -


in trying update database tag data on posts have function looks like

(defn add-tag-to-post [eid email tags]   (d/transact conn [{:db/id eid,                      :author/email email,                      :post/tag tags}])) 

unfortunately, not preserve tags (unless query time). append tags list instead of write new one.

example:

{:title "straight edges",   :content "fold instead of tearing it.  ",   :tags "scissor-less edges", ;;check out these awesome tags  :author "me@website.hax"  :eid 1759}     (add-tag-to-post 1759 "me@website.hax" "art") ;;desired behavior: adds tag "art" list of tags  (get-post-by-eid 1759) ;;returns   {:title "straight edges",   :content "fold instead of tearing it.  ",   :tags "art", ;;not cumulative tag addition ;/  :author "me@website.hax"  :eid 1759}   

how can achieved?

does make more sense query on lifetime of entity instead?

you'll need make :post/tag attribute have :cardinality/many - see :db/cardinality in http://docs.datomic.com/schema.html.

by default, attributes have :cardinality/one automatically retracts old values when overwritten. :cardinality/many cancels out behaviour.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -