At

At( timestamp, expression )
At( timestamp, expression )
At( timestamp, expression )
At( timesamp, expression )
at( timestamp, expression )
At( timestamp, expression )

Description

The At function executes a temporal query, a query which examines the data in the past. The timestamp parameter determines the data available for viewing by creating a virtual snapshot of the data which was current at that date and time. All reads from the associated expression is then executed on that virtual snapshot. In contrast, all write operations must be executed at the current time. Attempting a write operation at any other time produces an error.

Parameters

Argument Type Definition and Requirements

timestamp

A Function Ref

The date and time of the virtual snapshot of the data.

expression

Expressions

The FQL statement to be executed.

Returns

The evaluation of the expression at the given timestamp.

Examples

The query below creates a snapshot of the data to read at "1970-01-01" and retrieves all collections that existed on that date.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{
          "at": { "@ts": "1970-01-01T00:00:00Z" },
          "expr": { "paginate": { "@ref": "classes" } }
        }'
client.Query(
  At(Time("1970-01-01T00:00:00Z"), Paginate(Ref("collections"))));
System.out.println(
        client.query(
                At(
                  Time(Value("1970-01-01T00:00:00Z")),
                  Paginate(Ref("collections"))
                )
        ).get());
result, _ := client.Query(
    f.At(
        f.Time("1970-01-01T00:00:00Z"),
        f.Paginate(f.Collections()),
    ),
)

fmt.Println(result)
client.query(
  At(Time("1970-01-01T00:00:00Z"), Paginate(Ref("collections"))))
client.query(
  q.at(
    q.time("1970-01-01T00:00:00Z"),
    q.paginate(Ref("collections"))
  ))
client.query(
  q.At(
    q.Time('1970-01-01T00:00:00Z'),
    q.Paginate(q.Collections()),
  )
)
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": { "data": [ ] } }
{ "data": [ ] }
{data: []}
map[data:[]]
{ "data": [ ] }
{ "data": [ ] }
{ data: [] }

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!