Events
Events( input )
Description
The Events
function returns a Set of events for the
provided Reference. These events represent the history of the
reference, and demonstrate when the reference was created, modified, or
removed.
The kinds of events vary based on the kind of reference provided:
- Singular references
-
-
create
-
delete
-
update
-
- Set references
-
-
add
-
remove
-
Returns
A Set containing the creation, modification, or deletion events related to the provided input. Each event in the set contains the following fields:
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
The action applied to the |
|
|
Optional: only provided for documents containing user-supplied data. The data involved in the event. |
|
|
The Reference identifies the document associated with the event. |
|
|
The timestamp, with microsecond resolution, associated with the event. |
Examples
The following query fetches the events for a regular document:
Events(Ref(Collection("posts"), "233555580689580553"))
And again, using Paginate
to see the details of each event:
{
data: [
{
ts: 1624310406540000,
action: 'create',
document: Ref(Collection("posts"), "233555580689580553"),
data: { title: 'What I had for breakfast ..' }
},
{
ts: 1624310406640000,
action: 'update',
document: Ref(Collection("posts"), "233555580689580553"),
data: { tags: [ 'eggs', 'toast' ] }
},
{
ts: 1624310406660000,
action: 'delete',
document: Ref(Collection("posts"), "233555580689580553"),
data: null
}
]
}
The following query fetches the events while using Singleton
:
{
data: [
{
ts: 1624310406540000,
action: 'add',
document: Ref(Collection("posts"), "233555580689580553")
},
{
ts: 1624310406660000,
action: 'remove',
document: Ref(Collection("posts"), "233555580689580553")
}
]
}
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!