我正在使用 datomic 和 play 框架。游戏非常精彩,datomic 速度很快。所以总体来说是一个很好的组合。因为,我是 datomic (和数据日志,即查询语言 datomic 使用)的新手,所以我无法对结果进行排序(就像我们一样,在 sql 中排序)。例如。
如果我的查询是:
q= [:find ?title
:where
[?e :movie/title ?title]
[?e :movie/director "Dave Swag"]
[?e :movie/year ?year]
[(sort ?year)] //here I am trying to sort by year
]
它应该返回导演为 Dave Swag 的电影的标题,结果按图像发布的年份排序。谢谢 :)
如果你想对结果进行排序set,您需要在查询之外的返回结果集上执行此操作。有一个这样的例子关于查询的 Datomic 博客文章 http://blog.datomic.com/2013/05/a-whirlwind-tour-of-datomic-query_16.html在清单 20 中:
(def hist (d/history db))
(->> (d/q '[:find ?tx ?v ?op
:in $ ?e ?attr
:where [?e ?attr ?v ?tx ?op]]
hist
editor-id
:user/firstName)
(sort-by first))
=> ([13194139534319 "Ed" true]
[13194139534335 "Ed" false]
[13194139534335 "Edward" true])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)