Datomic文档显示了如何递归选择某些属性:
[:person/firstName :person/lastName {:person/friends 6}]
但是我想要提取所有属性(我在查询时不知道它们)。
[* {:person/friends 6}]
不再发生......是否有一张通配符排除了我想重复出现的关系?有没有办法在拉动AND使用通配符上进行递归规范?
或者有更好的方法来构建此查询吗?
答案 0 :(得分:0)
蒂莫西,
您应该可以使用["*" {:person/friends 6}]
来查找您正在寻找的行为。
使用Day of Datomic pull_recursion.clj中的示例:
(d/pull (d/db conn) '[:person/name {:person/friend 2}] anne-id)
;; {:person/name "anne", :person/friend [{:person/name "bob", :person/friend [{:person/name "anne"} {:person/name "lucille"}]} {:person/name "james", :person/friend [{:person/name "anne"} {:person/name "lucille"}]}]}
(d/pull (d/db conn) '["*" {:person/friend 2}] anne-id)
;; {":db/id" 17592186045418, ":person/name" "anne", ":person/friend" [{":db/id" 17592186045419} {":db/id" 17592186045420}], :person/friend [{":db/id" 17592186045419, ":person/name" "bob", ":person/friend" [{":db/id" 17592186045418} {":db/id" 17592186045421}], :person/friend [{":db/id" 17592186045418, ":person/name" "anne", ":person/friend" [{":db/id" 17592186045419} {":db/id" 17592186045420}], :person/friend [{":db/id" 17592186045419} {":db/id" 17592186045420}]} {":db/id" 17592186045421, ":person/name" "lucille", ":person/friend" [{":db/id" 17592186045419}], :person/friend [{":db/id" 17592186045419}]}]} {":db/id" 17592186045420, ":person/name" "james", ":person/friend" [{":db/id" 17592186045418} {":db/id" 17592186045421}], :person/friend [{":db/id" 17592186045418, ":person/name" "anne", ":person/friend" [{":db/id" 17592186045419} {":db/id" 17592186045420}], :person/friend [{":db/id" 17592186045419} {":db/id" 17592186045420}]} {":db/id" 17592186045421, ":person/name" "lucille", ":person/friend" [{":db/id" 17592186045419}], :person/friend [{":db/id" 17592186045419}]}]}]}
马歇尔