Temporal Queries
Bases can be configured to store some or all past revisions of content with Version Control Settings. In addition, repository snapshots preserve a revision of all content as it existed in a repository at a specific moment in time.
Past revisions, no matter how or why they were created, are available to be reviewed and restored from the Form View Versions Sidebar.
In addition, webCOMAND cPath, cQL and APIs can perform transaction time (TT) queries against revisions available for a specific point in time. In other words, a repository can be queried to retrieve results as they would've been returned at a specific time in the past, as long as the content revisions are still available (can be guaranteed with version control settings and/or snapshots).
Transaction Times
A transaction time (TT) query is performed by specifying the point in time to query against, which may be specified in one of the following formats.
- Date or Timestamp - A date or timestamp (date and time). For example, "2020-04-17 12:00:00".
- Revision Number - A number that represents a repository transaction, available from the PHP API.
- Workflow State - One of the keywords: Active, Draft, Working.
- Relative Format - A human-readable relative date-time, like 'yesterday' or '2 minutes ago', as supported by relative formats.
Internally, all formats except Workflow State are translated to the nearest valid revision number, which is used to determine query results available at that point in the revision history.
Transaction Time Queries
cPath and cQL have their own syntax to specify the transaction time to query on.
cPath
To specify a TT in cPath, use the '@' symbol followed by a transaction time.
Example Timestamp
/Bases/Website/[:WebPage]@'2020-04-17 12:00:00'
Example Relative Format
/Bases/Website/[:WebPage]@yesterday
Example Revision Number
/Bases/Website/[:WebPage]@1234
cQL
To specify a TT in cQL, use the AS OF clause.
Example Timestamp
SELECT * FROM WebPage IN /Bases/Website AS OF '2020-04-17 12:00:00'
Example Relative Format
SELECT * FROM WebPage IN /Bases/Website AS OF yesterday
Example Revision Number
SELECT * FROM WebPage IN /Bases/Website AS OF 1234
API
In addition, the PHP API can also set a transaction time for all queries that do not explicitly specify a transaction time. Set the transaction time with the timestamp or revision option when connecting to the repository with comand::connect().