datomic - 排除某些 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])
解决方案
事实证明,我可以通过使用标量输入而不是集合输入来做到这一点:
(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})
推荐阅读
- acumatica - Acumatica 网格中的附加选择器窗口
- swift - UIButton semanticContentAttribute 属性在 Localization 中被强制 RTL
- c++ - 为什么浮点数相等时给我的答案与整数不同
- autodesk-forge - 使用为大型模型分配内存的 FORGE 查看器中的模型闪烁并丢失
- apache-spark - 当工作节点上的数据可用但现在有可用于执行任务的计算资源时,Spark 会发生什么?
- excel - Long FormulaArray - .Replace 的编译错误
- python - 如何为字符串位序列编写递归
- c# - Silverlight C# 显示来自 SQL Server 的数据
- python - Python 类实例共享相同的值
- java - 如何在java中声明字典字典