首页 > 解决方案 > 排除某些 id 的查询

问题描述

我想编写一个查询,提供将被过滤掉的实体 ID 列表。

以下查询仍然返回 id 列表中的所有内容

(d/q '[:find (pull ?e [:db/id
                       :user/first-name])
       :in $ ?account [?id ...]
       :where [?e :user/account ?account]
              (not [(= ?e ?id)])]
     db 18625726974632500 [40809473576669559 47437329668874807])

标签: datomic

解决方案


事实证明,我可以通过使用标量输入而不是集合输入来做到这一点:

(d/q '[:find (pull ?e [:db/id
                       :user/first-name])
       :in $ ?account ?ids
       :where [?e :user/account ?account]
              (not [(contains? ?ids ?e)])]
     db 18625726974632500 #{40809473576669559 47437329668874807})

推荐阅读