我的问题是--有没有一种方法可以在数据中连接两个在模式中没有引用的实体,而不需要编写两个嵌套的迭代器(手动连接)。
在Datomic Doco中-他们给出了一个example of a query specifying two parameters。
[:find ?n ?u
:where
[?c :community/name ?n]
[?c :community/url ?u]]他们称之为“连接”--因为底层结构是一个键值数据库--所以即使是同一实体的属性也需要“连接”在一起。
然后,他们给出了一个具有引用的两个实体之间的连接示例(假设引用是在模式中定义的,这里没有显示):
[:find ?c_name
:where
[?c :community/name ?c_name]
[?c :community/neighborhood ?n]
[?n :neighborhood/district ?d]
[?d :district/region :region/ne]]我的问题是-在模式中没有引用的情况下,像上面这样的查询是可能的吗?或者,我是否必须编写迭代器并遍历结果?
发布于 2013-01-31 23:23:24
在:where子句中出现多次的任何变量都会被隐式连接起来。
因此,您可以要求输入属于某个社区和某个邻里社区的名称
(def results (q '[:find ?name :where [_ :neighborhood/name ?name]
[_ :district/name ?name]]
(db conn)))这是你要的东西吗?(本例中忽略了in )
https://stackoverflow.com/questions/14602506
复制相似问题