我正在尝试通过REST API在Datomic中进行"外连接".来自https://github.com/Datomic/day-of-datomic/blob/master/tutorial/social_news.clj我已经采取了最后的例子:
(defn maybe
"Returns the set of attr for e, or nil if e does not possess
any values for attr."
[db e attr]
(seq (map :a (d/datoms db :eavt e attr))))
;; find all users
(q '[:find ?e ?upvote
:where
[?e :user/email]
[(user/maybe $ ?e :user/upVotes) ?upvote]]
(db conn))
Run Code Online (Sandbox Code Playgroud)
我将maybe函数插入到我的数据库中,因此可以查询:
[:find ?n ?v :in $ :where [?e ?a ?v] [?a :db/ident :db/fn] [?e :db/ident ?n]]
Run Code Online (Sandbox Code Playgroud)
回报
:maybe #db/fn{:code "(seq (map :a (d/datoms db :eavt e attr)))", …Run Code Online (Sandbox Code Playgroud) datomic ×1