At

At( timestamp, expression )
At( timestamp, expression )
At( timestamp, expression )
At( timestamp, 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

Parameter Type Definition and Requirements

timestamp

The timestamp of the virtual snapshot of the data.

Do not set a timestamp in the future. If you do, your queries can stall and result in failed transactions.

If you are attempting to synchronize multiple clients, use the driver’s syncLastTxnTime function.

expression

FQL expression

The FQL statement to be executed.

Returns

The result of the evaluation of expression at the given timestamp.

Examples

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

try
{
    Value result = await client.Query(
        At(Time("1970-01-01T00:00:00Z"), Paginate(Ref("collections")))
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr())
result, err := client.Query(
	f.At(
		f.Time("1970-01-01T00:00:00Z"),
		f.Paginate(f.Collections())))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[]]
System.out.println(
    client.query(
        At(
            Time(Value("1970-01-01T00:00:00Z")),
            Paginate(Ref("collections"))
        )
    ).get());
{data: []}
client.query(
  q.At(
    q.Time('1970-01-01T00:00:00Z'),
    q.Paginate(q.Collections()),
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{ data: [] }
result = client.query(
  q.at(
    q.time("1970-01-01T00:00:00Z"),
    q.paginate(q.ref("collections"))
  )
)
print(result)
{'data': []}
At(
  Time('1970-01-01T00:00:00Z'),
  Paginate(Collections()),
)
{ data: [] }
Query metrics:
  •    bytesIn:   79

  •   bytesOut:   24

  • computeOps:    1

  •    readOps:    8

  •   writeOps:    0

  •  readBytes:  754

  • writeBytes:    0

  •  queryTime: 11ms

  •    retries:    0

Was this article helpful? 

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

Thank you for your feedback!