Exists

Exists( ref, [ts] )
Exists( ref, [ts] )
Exists( ref, [ts] )
Exists( ref, [ts] )
exists( ref, [ts]
exists  ref, [ts] )
Exists( ref, [ts] )
Exists( ref, [ts] )

Description

The Exists function returns boolean true if the provided ref exists at the specified timestamp (in the case of an instance), or is non-empty (in the case of a set), and false otherwise.

Parameters

Argument Type Definition and Requirements

ref

Reference

The reference identifier within the database uniquely identifying an instance.

ts

Long

Optional - Existence of the ref is checked at the given Timestamp. Defaults to the current time.

Returns

A boolean value

Examples

The query below checks for the existence of a ref pointing at an instance in the spells class at value 181388642046968320L. Since this ref is present at the current time, true is returned.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "exists": { "@ref": "classes/spells/181388642046968320" } }'
client.Query(Exists(Ref("classes/spells/181388642046968320")));
System.out.println(
       client.query(
               Exists(Ref(
                       Class("spells"),
                       Value(181388642046968320L)
                       )
               )
       ).get());
result, _ := client.Query(
    f.Exists(f.RefClass(f.Class("spells"), "181388642046968320")),
)

fmt.Println(result)
client.query(Exists(Ref("classes/spells/181388642046968320")))
client.query(q.exists(Ref("classes/spells/181388642046968320")))
$client.query do
  exists ref('classes/spells/181388642046968320')
end
client.query(
    Exists(Ref("classes/spells/181388642046968320"))
)
client.query(q.Exists(q.Ref(q.Class("spells"), 181388642046968320)))
  .then((ret) => console.log(ret));
HTTP/1.1 200 OK
{ "resource": true }
true
true
true
true
true
true
true
true

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!