Time Travel Guide
One of ChronDB's most powerful features is time travel - the ability to view, query, and work with your data as it existed at any point in time. This tutorial will guide you through practical examples of how to use time travel in your applications.
What is Time Travel?
In ChronDB, every change to your data is preserved. Nothing is ever truly deleted or overwritten. This means you can:
View any document as it existed at a specific point in time
Compare different versions of a document
Restore previous versions
Query your entire database as it existed in the past
Analyze how your data has evolved
Time Travel Use Cases
Time travel is invaluable for many scenarios:
Audit trails - See who changed what and when
Debugging - Understand when a data issue was introduced
Compliance - Fulfill regulatory requirements for data history
Analytics - Compare trends over time
Undo - Recover from mistakes or data corruption
Tutorial Setup
Before starting, make sure you have ChronDB running:
Exercise 1: Creating Documents with History
Let's create a document and track its evolution:
Using the REST API
Exercise 2: Viewing Document History
Now that we have a document with multiple versions, let's explore its history:
REST API
Redis Protocol
PostgreSQL Protocol
Clojure API
Exercise 3: Time-Travel Queries
Now let's retrieve specific versions of our document:
REST API
Redis Protocol
PostgreSQL Protocol
Clojure API
Exercise 4: Comparing Versions
Let's examine what changed between versions:
REST API
Redis Protocol
PostgreSQL Protocol
Clojure API
Exercise 5: Reverting to a Previous Version
Sometimes you need to restore data to a previous state:
Clojure API (most direct way)
REST API
Exercise 6: Checking Who Made Changes (Audit Trail)
ChronDB tracks metadata about each change. Let's see who changed what:
PostgreSQL Protocol (includes committer info)
Clojure API with Metadata
Exercise 7: Branching and Time Travel
ChronDB's branching feature works seamlessly with time travel. Let's see how:
Creating a Test Branch
Real-World Application: Feature Flagging with Time Travel
Let's implement a practical example: using ChronDB's time travel for feature flagging and rollbacks:
Conclusion
Time travel is one of ChronDB's most powerful features. By preserving the complete history of your data, ChronDB enables:
Complete audit trails
Point-in-time recovery
Historical analysis
Safe experimentation with branching
Compliance with data retention requirements
In this tutorial, you've learned how to:
Create and update documents to build history
View the complete history of a document
Retrieve specific historical versions
Compare different versions
Revert to previous versions
Track who made changes
Use branching with time travel
Implement practical time travel patterns
For more advanced time travel techniques, check out the Version Control documentation.
Next Steps
Data Model - Understand ChronDB's document structure
Branching Guide - Learn more about branching
Performance Considerations - Optimize for time travel queries
Community Resources
Documentation: chrondb.avelino.run
Questions & Help: Discord Community
Share Your Experience: GitHub Discussions
Last updated
Was this helpful?