在尝试更新帖子上的数据库标记数据时,我有一个类似于
(defn add-tag-to-post [eid email tags]
(d/transact conn [{:db/id eid,
:author/email email,
:post/tag tags}]))不幸的是,这不会保留标记(除非我按时间进行查询)。我想简单地附加到标签列表,而不是写一个新的。
示例:
{: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" to the 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} 如何才能做到这一点?
仅仅在实体的生存期内进行查询更有意义吗?
发布于 2015-03-17 12:21:35
您需要使您的:post/tag属性具有:cardinality/many -参见http://docs.datomic.com/schema.html中的:db/cardinality。
默认情况下,属性有:cardinality/one,当旧值被覆盖时,它会自动撤回旧值。:cardinality/many取消了这种行为。
https://stackoverflow.com/questions/29090599
复制相似问题