link:example$test/xtdb/docs/examples/query_test.clj[role=include]
XTDB is a schemaless document database that provides you with a comprehensive means of traversing and querying across all of your documents. XTDB automatically indexes the top-level fields in all documents, supporting efficient ad-hoc joins and retrievals. XTDB is both immutable and bitemporal, which are both required characteristics for a safe schemaless database.
XTDB is also a graph database. The central characteristic of a graph database is that it can support arbitrary-depth graph queries (recursive traversals) very efficiently by default, without any need for schema-level optimisations. Graph queries are possible through the XTDB dialect of the Datalog query language.
Extensible Data Notation (edn) is a simple data format that is used to describe XTDB Datalog queries. To understand how edn works, read the brief description at http://edn-format.org.
To learn about Datalog queries and get familiar with the concepts, read the Learn XTDB Datalog Today tutorial.
A query in XTDB is performed by calling xt/q
on an XTDB database snapshot with a quoted map and, optionally, additional arguments.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Database value. Usually the snapshot view comes from calling xt/db on an XTDB node |
2 | Query map or vector (ex. [:find …etc… ] , as found in other Datalog databases) |
3 | Argument(s) supplied to the :in relations |
The query map accepts the following Keywords
Key | Type | Purpose |
---|---|---|
Vector | Specify values to be returned | |
Vector | Restrict the results of the query | |
Vector | Specify external arguments | |
Vector | Control the result order | |
Int | Specify how many results to return | |
Int | Specify how many results to discard | |
Vector | Define powerful statements for use in | |
Int | Specify maximum query run time in ms |
The find clause of a query specifies what values to be returned. These will be returned as a vector.
You can directly specify a logic variable from your query.
The following will return all last names bound to the logic variable n
.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
You can use basic Clojure-like expressions within a :find
parameter.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
let
, and other macros are unsupported - you can create and call fully-qualified Clojure functions for more advanced use cases.
Function calls are guarded by :fn-allow-list
, if it was specified in the node configuration.
You can specify an aggregate function to apply to at most one logic variable.
Usage | Description |
| Accumulates as a single value via the Clojure |
| Return a single value via the Clojure |
| |
| Return a single count of all values including any duplicates (note: this always performs a scan - no statistics or other stateful materializations are used) |
| Return a single value equivalent to |
| Return a single value corresponding to the statistical definition |
| |
| |
| Return a vector of exactly N values, where some values may be duplicates if N is larger than the range |
| Return a vector of at-most N distinct values |
| Return a set of distinct values |
Aggregates cannot be nested within another - e.g. (sum (count ?x))
is disallowed.
Results are implicitly grouped by all logic variables referred to outside of aggregations (even if the same variables are also referred to within aggregations).
For example, in the following example, the results are grouped by ?a
and ?b
:
{:find [?a (/ ?b (sum (+ ?b ?c)))], ...}
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
;; =>
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Custom (user-defined) aggregates are supported by adding a new method (via Clojure defmethod
) for xtdb.query/aggregate
.
This method takes a single (ignored) parameter and returns a multi-arity function which accepts zero parameters, an accumulator, or an accumulator and a single entity.
For example:
(defmethod xtdb.query/aggregate 'sort-reverse [_]
(fn
([] [])
([acc] (vec (reverse (sort acc))))
([acc x] (conj acc x))))
XTDB queries support a pull
syntax, allowing you to decouple specifying which entities you want from what data you’d like about those entities in your queries.
XTDB’s support is based on the excellent EDN Query Language (EQL) library.
To specify what data you’d like about each entity, include a (pull ?logic-var projection-spec)
entry in the :find
clause of your query:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
You can quickly grab the whole document by specifying *
in the projection spec:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
If you have the entity id(s) in hand, you can call pull
or pull-many
directly:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
We can navigate to other entities (and hence build up nested results) using joins.
Joins are specified in {}
braces in the projection-spec - each one maps one join key to its nested spec:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
We can also navigate in the reverse direction, looking for entities that refer to this one, by prepending _
to the attribute name:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
XTDB pull
syntax supports a handful of custom EQL parameters, specified by wrapping the :attribute
key in a pair: (:attribute {:param :value, …})
.
:as
- to rename attributes in the result, wrap the attribute in (:source-attribute {:as :output-name})
:
{:find [(pull ?profession [:profession/name
{(:user/_profession {:as :users}) [:user/id :user/name]}])]
:where [[?profession :profession/name]]}
;; => [{:profession/name "Doctor",
;; :users [{:user/id 1, :user/name "Ivan"},
;; {:user/id 3, :user/name "Petr"}]},
;; {:profession/name "Lawyer",
;; :users [{:user/id 2, :user/name "Sergei"}]}]
:limit
- limit the amount of values returned under the given property/join: (:attribute {:limit 5})
:default
- specify a default value if the matched document doesn’t contain the given attribute: (:attribute {:default "default"})
:into
- specify the collection to pour the results into: (:attribute {:into #{}})
{:find [(pull ?profession [:profession/name
{(:user/_profession {:as :users, :into #{}})
[:user/id :user/name]}])]
:where [[?profession :profession/name]]}
;; => [{:profession/name "Doctor",
;; :users #{{:user/id 1, :user/name "Ivan"},
;; {:user/id 3, :user/name "Petr"}}},
;; {:profession/name "Lawyer",
;; :users #{{:user/id 2, :user/name "Sergei"}}}]
:cardinality
(reverse joins) - by default, reverse joins put their values in a collection - for many-to-one/one-to-one reverse joins, specify {:cardinality :one}
to return a single value.
For full details on what’s supported in the projection-spec, see the EQL specification
To return maps rather than tuples, supply the map keys under :keys
for keywords, :syms
for symbols, or :strs
for strings:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
The :where
section of a query limits the combinations of possible results by satisfying all clauses and rules in the supplied vector against the database (and any :in
relations).
Name | Description |
Restrict using EAV indexes | |
Restrict with any predicate | |
Restrict with any of | |
Unify two distinct logic variables with | |
Negate a list of clauses | |
Not rule with its own scope | |
Restrict on at least one matching clause | |
Or with its own scope | |
Restrict with a user-defined rule |
Clauses may refer to combinations of literal values and logic variables as inputs.
Identical logic variables used across multiple clauses unify automatically (with the exception of or-join
or not-join
scoping).
A literal set containing literal values (e.g. #{"val-1" "val-2"}
) will be interpreted as an input relation of distinct values, and can be used in place of any literal input (e.g. a set of entity IDs in the first position of a triple clause).
A triple clause is a vector of (1) a literal entity ID or a logic variable, (2) a hard-coded attribute keyword (top-level key in a document), and (3) optionally, a value which can be a literal or a logic variable.
It restricts results by matching EAV facts
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | This matches all entities, p , which have a :name field. |
2 | This matches all entities, p , which have a :name of "Ivan" . |
3 | This matches all entities, p , which have a :name which match the :last-name of q . |
Note that the keyword attribute must always be specified and therefore you cannot use a logic variable in the attribute position.
You can however enumerate combinations of known attributes using rules, or execute independent queries efficiently using openDB
(open-db
).
A list of all known attributes is available via the attributeStats
(attribute-stats
) API.
Any fully qualified Clojure function that returns a boolean can be used as a "filter" predicate clause.
Predicate clauses must be placed in a clause, i.e. with a surrounding vector.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
This matches all entities, p
which have an odd :age
.
You can nest a subquery with a :where
clause to bind the result for further use in the query.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
In the above query, we perform a subquery doing some arithmetic operations and returning the result - and bind the resulting relation as a scalar.
Result set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Similar to the previous query, except we bind the resulting relation as a tuple.
Result set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
In this example, we bind the results of a subquery and use them to return another result.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Result set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Any fully qualified Clojure function can also be used to return relation bindings in this way, by returning a list, set or vector.
A range predicate
is a vector containing a list of a range operator and then two logic variables or literals.
Allowed range operators are <
, <=
, >=
, >
, and =
.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Finds any entity, p , with an :age which is greater than 18 |
2 | Finds any entity, p , with an :age which is greater than the :age of any entity |
3 | Finds any entity, p , for which 18 is greater than :age of p |
Use a unification predicate, either ==
or !=
, to constrain two independent logic variables. Literals (and sets of literals) can also be used in place of one of the logic variables.
;; Find all pairs of people with the same age:
[[p :age a]
[p2 :age a2]
[(== a a2)]]
;; ...is approximately equivalent to...
[[p :age a]
[p2 :age a]]
;; Find all pairs of people with different ages:
[[p :age a]
[p2 :age a2]
[(!= a a2)]]
;; ...is approximately equivalent to...
[[p :age a]
[p2 :age a2]
(not [(= a a2]])]
The not
clause rejects a graph if all the clauses within it are true.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Data |
2 | Query |
3 | Result |
This will match any document which does not have a :name
of "Ivan" and a :last-name
of "Ivanov".
The not-join
rule allows you to restrict the possibilities for logic variables by asserting that there does not exist a match for a given sequence of clauses.
You declare which logic variables from outside the not-join
scope are to be used in the join.
Any other logic variables within the not-join are scoped only for the join.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Data |
2 | Declaration of which logic variables need to unify with the rest of the query |
3 | Clauses |
4 | Result |
This will match any entity, p
, which has different values for the :name
and :last-name
field.
Importantly, the logic variable n
is unbound outside the not-join
clause.
An or
clause is satisfied if any of its legs are satisfied.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Data |
2 | Query |
3 | Result |
This will match any document, p
, which has a :last-name
of "Ivanov" or "Ivannotov".
When within an or
rule, you can use and
to group clauses into a single leg (which must all be true).
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Whenever the query engine complains that each leg in the or
or or-join
clause requires the "same logic variables", you can add a no-op predicate clause like [(any? e)]
within and
clauses for each of the missing variables in the various legs.
You need to add such no-op predicates until each leg contains the same set of variables.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Hypothetically, XTDB could automatically detect these cases and insert no-op predicates on the user’s behalf, but that would be a deviation from the essential semantics of Datalog.
Note that clojure.core/any?
is a function that always returns true
.
The or-join
clause is satisfied if any of its legs are satisfied.
You declare which logic variables from outside the or-join
scope are to be used in the join.
Any other logic variables within the or-join
are scoped only for the join.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Data |
2 | Declaration of which logic variables need to unify with the rest of the query |
3 | Clauses |
4 | Result |
This will match any document, p
which has an :age
greater than or equal to 18 or has a :name
of "Ivan".
Importantly, the logic variable a
is unbound outside the or-join
clauses.
XTDB queries can take a set of additional arguments, binding them to variables under the :in
key within the query.
:in
supports various kinds of binding.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
In the above query, we parameterize the first-name
symbol, and pass in "Ivan" as our input, binding "Ivan" to first-name
in the query.
Result Set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
This query shows binding to a collection of inputs - in this case, binding first-name
to all of the different values in a collection of first-names.
Result Set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
In this query we are binding a set of variables to a single value each, passing in a collection as our input. In this case, we are passing a collection with a first-name
followed by a last-name
.
Result Set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Here we see how we can extend the parameterisation to match using multiple fields at once by passing and destructuring a relation containing multiple tuples.
Result Set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
A Datalog query naturally returns a result set of tuples, however, the tuples can also be consumed as a sequence and therefore you will always have an implicit order available. Ordinarily this implicit order is undefined (i.e. not meaningful), because the join order and result order are unlikely to correlate.
The :order-by
option is available for use in the query map to explicitly
control the result order.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Use of :order-by
will require that results are fully-realised by the query
engine, however this happens transparently and it will automatically spill to
disk when sorting large numbers of results.
Basic :offset
and :limit
options are supported however typical pagination
use-cases will need a more comprehensive approach because :offset
will
naively scroll through the initial result set each time.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Ordered results are returned as bags, not sets, so you may want to deduplicate
consecutive identical result tuples (e.g. using clojure.core/dedupe
or
similar).
:limit
may be used in isolation, without :order-by
, and will also return a
bag of results that can contain duplicates.
To use :order-by
with an aggregate, simply restate the aggregate element exactly as it is written in your :find
vector.
More powerful ordering and pagination features may be provided in the future. Feel free to open an issue or get in touch to discuss your ordering requirements, e.g. see #1514
Rules are defined by a rule head and then clauses as you would find in a :where
statement.
They can be used as a shorthand for when you would otherwise be repeating the same restrictions in your :where
statement.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Rule usage clause (i.e. invocation) |
2 | Rule head (i.e. signature) |
3 | Rule body containing one or more clauses |
The above defines the rule named adult?
which checks that the supplied entity has an :age
which is >=
18
Multiple rule bodies may be defined for a single rule name (i.e. using matching rule heads) which works in a similar fashion to an or-join
.
The clauses within Rules can also be further Rule invocation clauses. This allows for the recursive traversal of entities and more.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
This example finds all entities that the entity with :name
"Smith" is connected to via :follow
, even if the connection is via intermediaries.
To improve the performance of a rule you can specify that certain arguments in the rule head must be "bound" logic variables (i.e. there must be known values for each argument at the point of evaluation) by enclosing them in a vector in the first argument position. Any remaining arguments will be treated as regular "free" logic variables.
As an analogy, bound variables are input arguments to a function, and free variables are the destructured return values from that function.
Changes are only necessary in the rule head(s) - no changes are required in the body or the usage clauses. Rule heads must always match.
For example, the following query and rule set will work and return the correct results.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
However, specifying that the p
variable should be bound before the rule can be evaluated will improve the evalution time by many orders-of-magnitude for large data sets.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
:timeout
sets the maximum run time of the query (in milliseconds).
If the query has not completed by this time, a java.util.concurrent.TimeoutException
is thrown.
When performing a query, xt/q
is called on a database snapshot.
To query based on a different Valid Time, create this snapshot by specifying the desired Valid Time when we call db
on the node.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Here, we have put
different documents in XTDB with different Valid Times.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Here, we have defined a query, q
to find all entities with a :name
of "Malcolma" and :last-name
of "Sparks"
We can run the query at different Valid Times as follows
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
The first query will return an empty result set (#{}
) because there isn’t a document with the :name
"Malcolma" valid at #inst "1986-10-23"
The second query will return #{[:malcolm]}
because the document with :name
"Malcolma" is valid at the current time.
This will be the case so long as there are no newer versions (in the valid time axis) of the document that affect the current valid time version.
Given the following documents in the database
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
We can run a query to return a set of tuples that satisfy the join on the attribute :name
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Result Set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Note that every person joins once, plus 2 more matches.
Given the following documents in the database
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
We can run a query to return a set of entities that :follows
the set of entities with the :name
value of "Ivan"
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Result Set:
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
Note that because XTDB is schemaless there is no need to have elsewhere declared that the :follows
attribute may take a value of edn type set
.
Query results can also be streamed, particularly for queries whose results may
not fit into memory. For these, we use xtdb.api/open-q
, which returns a
Closeable
sequence. Note that results are returned as bags, not sets, so you
may wish to deduplicate consecutive identical result tuples (e.g. using
clojure.core/dedupe
or similar).
We’d recommend using with-open
to ensure that the sequence is closed properly.
Additionally, ensure that the sequence (as much of it as you need) is eagerly
consumed within the with-open
block - attempting to use it outside (either
explicitly, or by accidentally returning a lazy sequence from the with-open
block) will result in undefined behaviour.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
XTDB allows you to retrieve all versions of a given entity:
link:example$test/xtdb/docs/examples_test.clj[role=include]
When retrieving the previous versions of an entity, you have the option to additionally return the documents associated with those versions (by using :with-docs?
in the additional options map)
link:example$test/xtdb/docs/examples_test.clj[role=include]
Retrievable entity versions can be bounded by four time coordinates:
valid-time-start
tx-time-start
valid-time-end
tx-time-end
All coordinates are inclusive. All coordinates can be null.
link:example$test/xtdb/docs/examples_test.clj[role=include]
See the open-entity-history
(Clojure) and openEntityHistory
(Java) APIs.
Logic variables used in queries must always be quoted in the :find
and
:where
clauses, which in the most minimal case could look like the following:
(xt/q db
{:find ['?e]
:where [['?e :event/employee-code '?code]]}))
However it is often convenient to quote entire clauses or even the entire query map rather than each individual use of every logic variable, for instance:
(xt/q db
'{:find [?e]
:where [[?e :event/employee-code ?code]]}))
Note that use of Clojure’s syntax quoting may cause confusion and is therefore not recommended. This is because Datalog built-ins like range predicates, unification predicates and rules (or
, not
etc.) will be mistakenly coerced into corresponding Clojure core functions (clojure.core/or
, clojure.core/==
etc.) and produce invalid queries.
Say you have a document like so and you want to add it to an XTDB db:
{:xt/id :me
:list ["carrots" "peas" "shampoo"]
:pockets {:left ["lint" "change"]
:right ["phone"]}}
XTDB breaks down vectors into individual components so the query engine is able
see all elements on the base level. As a result of this the query engine is not
required to traverse any structures or any other types of search algorithm
which would slow the query down. The same thing should apply for maps so
instead of doing :pocket {:left thing :right thing}
you should put them under
a namespace, instead structuring the data as :pocket/left thing :pocket/right
thing
to put the data all on the base level. Like so:
(xt/submit-tx
node
[[::xt/put
{:xt/id :me
:list ["carrots" "peas" "shampoo"]
:pockets/left ["lint" "change"]
:pockets/right ["phone"]}]
[::xt/put
{:xt/id :you
:list ["carrots" "tomatoes" "wig"]
:pockets/left ["wallet" "watch"]
:pockets/right ["spectacles"]}]])
To query inside these vectors the code would be:
(xt/q (xt/db node) '{:find [e l]
:where [[e :list l]]
:in [l]}
"carrots")
;; => #{[:you "carrots"] [:me "carrots"]}
(xt/q (xt/db node) '{:find [e p]
:where [[e :pockets/left p]]
:in [p]}
"watch")
;; => #{[:you "watch"]}
Note that l
and p
is returned as a single element as XTDB decomposes the
vector
This list is not necessarily exhaustive and is based on the partial re-usage of DataScript’s query test suite within XTDB’s query tests.
XTDB does not support:
vars in the attribute position, such as [e ?a "Ivan"]
or [e _ "Ivan"]
XTDB does not yet support:
ground
(you can use alternatively use identity
)
get-else
(see get-attr
which returns a relation instead)
get-some
missing?
(however, instead of [(missing? $ ?e :height)]
you can use (not-join [?e] [?e :height])
)
reverse attribute syntax in triple clauses (i.e. [?child :example/_child ?parent]
), however reverse attribute joins (like :example/_child
) are supported in pull
Many advanced query requirements can be addressed using custom predicate function calls since you can reference any function that is loaded (and available on the classpath) by using its fully qualified name in a Datalog clause, e.g. [(clojure.core/+ x y) z)]
.
These custom functions can be passed the db
query context using the $
argument convention for sophisticated nesting of queries and other lookups. Destructuring the results of a function as a relation is also supported, similarly to :in
bindings.
The suite of functions in the clojure.core
namespace may be referred to without the fully qualified prefix, including clojure.core/eval
, however an allowlist feature is available to help maintain security (particularly relevant when the HTTP server is being used).
These functions can be used, for example, to access data that is deeply nested with a given top-level value.
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
link:example$test/xtdb/docs/examples/query_test.clj[role=include]
1 | Data |
2 | Usage of clojure.core/get-in function with literal vector of keys |
3 | Usage of clojure.core/vector function to construct intermediate vector value |
4 | Result |
Be aware during development that query compilation internalizes function definitions and this means that subsequent re-definitions of your custom functions may not be reflected until the query is modified and therefore re-compiled. During development, you can introduce a dummy predicate clause like [(any? 1)]
(which always evaluates to true
and has no effect on the query) and increment the integer when needed to bypass the effects of query caching.
Many examples of advanced queries are showcased across the query tests and the suite of benchmarks maintained in the bench
sub-project.
Can you improve this documentation? These fine people already did:
Jeremy Taylor, James Henderson, Aleksander Sumowski & Steven DeobaldEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close