Events
Events( input )
Events( input )
Events( input )
Events( input )
events( input )
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:
SetRefV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Types.Value])
{map[events:{233555580689580553 0xc000192180 0xc000192180 <nil>}]}
{@set = {events: ref(id = "233555580689580553", collection = ref(id = "posts", collection = ref(id = "collections")))}}
Events(Ref(Collection("posts"), "233555580689580553"))
SetRef({'events': Ref(id=233555580689580553, collection=Ref(id=posts, collection=Ref(id=collections)))})
Events(Ref(Collection("posts"), "233555580689580553"))
And again, using Paginate
to see the details of each event:
ObjectV(data: Arr(ObjectV(ts: LongV(1603756294080000),action: StringV(create),document: RefV(id = "233555580689580553", collection = RefV(id = "posts", collection = RefV(id = "collections"))),data: ObjectV(title: StringV(What I had for breakfast ..))), ObjectV(ts: LongV(1603756294110000),action: StringV(update),document: RefV(id = "233555580689580553", collection = RefV(id = "posts", collection = RefV(id = "collections"))),data: ObjectV(tags: Arr(StringV(eggs), StringV(toast)))), ObjectV(ts: LongV(1603756294140000),action: StringV(delete),document: RefV(id = "233555580689580553", collection = RefV(id = "posts", collection = RefV(id = "collections"))),data: NullV)))
map[data:[map[action:create data:map[title:What I had for breakfast ..] document:{233555580689580553 0xc00009a240 0xc00009a240 <nil>} ts:1603747163140000] map[action:update data:map[tags:[eggs toast]] document:{233555580689580553 0xc00009a450 0xc00009a450 <nil>} ts:1603747163170000] map[action:delete data:{} document:{233555580689580553 0xc00019a0f0 0xc00019a0f0 <nil>} ts:1603747163190000]]]
{data: [{ts: 1593464840120000, action: "create", document: ref(id = "233555580689580553", collection = ref(id = "posts", collection = ref(id = "collections"))), data: {title: "What I had for breakfast .."}}, {ts: 1593464840150000, action: "update", document: ref(id = "233555580689580553", collection = ref(id = "posts", collection = ref(id = "collections"))), data: {tags: ["eggs", "toast"]}}, {ts: 1593464840170000, action: "delete", document: ref(id = "233555580689580553", collection = ref(id = "posts", collection = ref(id = "collections"))), data: null}]}
{
data: [
{
ts: 1592269279120000,
action: 'create',
document: Ref(Collection("posts"), "233555580689580553"),
data: { title: 'What I had for breakfast ..' }
},
{
ts: 1592269279150000,
action: 'update',
document: Ref(Collection("posts"), "233555580689580553"),
data: { tags: [ 'eggs', 'toast' ] }
},
{
ts: 1592269279170000,
action: 'delete',
document: Ref(Collection("posts"), "233555580689580553"),
data: null
}
]
}
{'data': [{'ts': 1592939385260000, 'action': 'create', 'document': Ref(id=233555580689580553, collection=Ref(id=posts, collection=Ref(id=collections))), 'data': {'title': 'What I had for breakfast ..'}}, {'ts': 1592939385290000, 'action': 'update', 'document': Ref(id=233555580689580553, collection=Ref(id=posts, collection=Ref(id=collections))), 'data': {'tags': ['eggs', 'toast']}}, {'ts': 1592939385310000, 'action': 'delete', 'document': Ref(id=233555580689580553, collection=Ref(id=posts, collection=Ref(id=collections))), 'data': None}]}
{
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
:
ObjectV(data: Arr(ObjectV(ts: LongV(1603756294080000),action: StringV(add),document: RefV(id = "233555580689580553", collection = RefV(id = "posts", collection = RefV(id = "collections")))), ObjectV(ts: LongV(1603756294140000),action: StringV(remove),document: RefV(id = "233555580689580553", collection = RefV(id = "posts", collection = RefV(id = "collections"))))))
map[data:[map[action:add document:{233555580689580553 0xc0000915c0 0xc0000915c0 <nil>} ts:1603747163140000] map[action:remove document:{233555580689580553 0xc0000917a0 0xc0000917a0 <nil>} ts:1603747163190000]]]
{data: [{ts: 1593464840120000, action: "add", document: ref(id = "233555580689580553", collection = ref(id = "posts", collection = ref(id = "collections")))}, {ts: 1593464840170000, action: "remove", document: ref(id = "233555580689580553", collection = ref(id = "posts", collection = ref(id = "collections")))}]}
{
data: [
{
ts: 1592269043990000,
action: 'add',
document: Ref(Collection("posts"), "233555580689580553")
},
{
ts: 1592269044060000,
action: 'remove',
document: Ref(Collection("posts"), "233555580689580553")
}
]
}
{'data': [{'ts': 1592939385260000, 'action': 'add', 'document': Ref(id=233555580689580553, collection=Ref(id=posts, collection=Ref(id=collections)))}, {'ts': 1592939385310000, 'action': 'remove', 'document': Ref(id=233555580689580553, collection=Ref(id=posts, collection=Ref(id=collections)))}]}
{
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!