SHOW
statement
The SHOW
statement can be used to replay changes made to a table.
Requirements
- You must first
DEFINE
a Change Feed.
Statement syntax
SurrealQL SyntaxSHOW CHANGES FOR TABLE @tableName [SINCE "@timestamp"] [LIMIT @number]
Example usage
Basic usage
The following expression shows usage of the SHOW statement.
-- Define the change feed and its duration
DEFINE TABLE reading CHANGEFEED 3d;
-- Create some records in the reading table
CREATE reading SET story = "Once upon a time";
CREATE reading SET story = "there was a database";
-- Replay changes to the reading table
SHOW CHANGES FOR TABLE reading SINCE "2023-09-07T01:23:52Z" LIMIT 10;
Response[
{
"changes": [
{
"define_table": {
"name": "reading"
}
}
],
"versionstamp": 29
},
{
"changes": [
{
"update": {
"id": "reading:h1gcbc7ykbpslellh2g2",
"story": "Once upon a time"
}
}
],
"versionstamp": 30
},
{
"changes": [
{
"update": {
"id": "reading:l9qfcncklhnlklby1avf",
"story": "there was a database"
}
}
],
"versionstamp": 31
}
]
Note: SINCE <time>
needs to be after the time the CHANGEFEED
was defined. Also, when defining a CHANGEFEED
on a table, it implicitly creates a CHANGEFEED
on the database.