Fork me on GitHub
#datomic
<
2022-05-10
>
johanatan01:05:11

is there any way to transform a result from :find (within the query itself)? for example, to create a query that returns true if [?somevar ...] has one or more elements in it and false if it has zero elements / is empty

johanatan01:05:44

or alternatively if ?a . is either nil or not nil

thumbnail05:05:34

An attribute cant be nil (only be omitted); but you can use an or/or-join to do this.

(or
 (and [?e :arrt _] [(ground true) ?mybool])
 (and (missing? ?e :attr) [(ground false) ?mybool]))
Here ?mybool is bound to either true or false depending if the preceding clause matches (Alternatively this can be expressed as a datomic rule too)

johanatan05:05:25

Thank you. I was wondering if it might have been possible within the :where bindings

johanatan17:05:58

does that needs to be or-join or will or suffice ?

onetom00:05:00

both or clauses refer to the same set of variables (`?e` and ?mybool), so i don't think u need or-join. > An or-join clause is similar to an or clause, but it allows you to specify which variables should unify with the surrounding clause; only this list of variables needs binding before the clause can run. The /variable/s specifies which variables should unify. — https://docs.datomic.com/cloud/query/query-data-reference.html#or-join

johanatan01:05:48

(as a boolean)