【发布时间】:2015-05-20 15:31:44
【问题描述】:
所以我有一些被标记的帖子,我希望用户能够添加标签,然后我希望能够进行查询并获得特定帖子的标签汇总列表。 (目前该行为只返回一个实体列表,每个实体都有不同的 :tags 属性。)
({:title "Straight edges ...",
:content "If you ever ... ",
:tags "folding", <<< +
:eid 1759}
{:title "Straight edges ...",
:content "If you ever ...",
:tags "art", <<< +
:eid 1759}
{:title "Straight edges ...",
:content "If you ever ... ",
:tags "scissor-less edges", <<< +
:eid 1759}
{:title "Straight edges ...",
:content "If you ever ... ",
:tags "snips", <<< +
:eid 1759}
{:title "Straight edges ...",
:content "If you ever ... ",
:tags "scissor-less edges", <<< ^ How to combine?
:eid 1759})
我的查询看起来像
(defn get-post-by-eid [eid]
(->> (d/q '[:find ?title ?content ?tags ?eid
:in $ ?eid
:where
[?eid post/title ?title]
[?eid post/content ?content]
[?eid post/tag ?tags]] (d/db conn) eid)
(map (fn [[title content tags eid]]
{:title title
:content content
:tags tags
:eid eid}))
(sort-by :eid)))
想要的结果是这样的
({:title "Straight edges ...",
:content "If you ever ... ",
:tags "folding, art, scissor-less edges, snips", ;;combination
:eid 1759}
关于如何查询此内容或如何将所有查询结果混合在一起的任何提示?提前致谢
【问题讨论】:
标签: clojure datomic data-retrieval