使用限制/默认值的查询中的表达式?

问题描述 投票:0回答:1

如何在查询的pull表达式中使用limit / default?给定一个cardinality-many属性,如何控制返回多少个值(默认为最大1000个值!)。

((很难从文档/示例中找出正确的语法)

datomic
1个回答
0
投票

限制(对于基数很多属性)

返回基数多属性:ns/ints的最大2个值:

[:find  (pull ?a [(limit :ns/ints 2)])
 :where [?a :ns/str ?b]]

返回基数多属性:ns/ints的所有值:

[:find  (pull ?a [(limit :ns/ints nil)])
 :where [?a :ns/str ?b]]

默认

如果属性2000没有值,则返回默认值:ns/ints

[:find  (pull ?a [(default :ns/ints 2000)])
 :where [?a :ns/str ?b]]

如果许多基数2000没有值,则返回默认值2001:ns/ints

[:find  (pull ?a [(default :ns/ints [2000 2001])])
 :where [?a :ns/str ?b]]
© www.soinside.com 2019 - 2024. All rights reserved.