【发布时间】:2015-05-20 06:34:40
【问题描述】:
我目前正在将我的 clojure 应用程序(使用 korma)迁移到 Datomic 框架,并且在我翻译查询时一直处于循环状态。我意识到查询并不完全灵活(与 korma 相比),例如我想评估围绕不同变量的条件子句。
考虑一个 korma 查询,
(select users
(where (or (and {:first_name [= "user"]}
{:last_name [= "sample"]})
{:email [= "user.sample@email.com"]})))
这可以转换为 Datomic,像这样?
[:find ?e
:where (or (and [?u :user/first-name "user"]
[?u :user/last-name "sample"])
[?u :user/email "user.sample@email.com"])
但这不是推荐的查询方式(根据 Datomic 文档),因为 or 子句中使用的所有子句必须使用相同的变量集。如何围绕不同的变量集设置 OR 子句?
【问题讨论】: