Eventbase is an advanced key-value store built on NATS JetStream, empowering you with event sourcing and real-time data subscriptions. With features like automatic metadata tracking and distributed state synchronization, it supports large datasets while providing a simple API for seamless data management.
Eventbase is a powerful distributed event-sourced database built on NATS JetStream, designed to provide an efficient and scalable key-value store with real-time value change streaming. This innovative solution leverages event sourcing to ensure robust data tracking, enabling automatic metadata management for your data entries.
Key Features
- Automatic Metadata Tracking: Keep track of creation dates, modification dates, and change counts effortlessly.
- Distributed State Synchronization: Maintain consistent data across multiple instances in real-time.
- Real-Time Data Subscriptions: Receive updates based on pattern matching to stay informed of data changes as they happen.
- Simple Key-Value API: Easy-to-use interface for storing and retrieving data.
- Support for Large Datasets: Handle extensive data loads without compromising performance.
- Pattern-Based Key Filtering: Quickly access keys using glob-style patterns, enhancing data retrieval capabilities.
- Special Character Support: Seamlessly use special characters in keys to ensure flexibility in naming conventions.
Quick Start Example
Begin by initializing the Eventbase in your application:
import createEventbase from '@markwylde/eventbase';
// Initialize Eventbase
const eventbase = await createEventbase({
nats: {
servers: ['localhost:4222']
},
streamName: 'myapp'
});
// Store data
await eventbase.put('user123', { name: 'John Doe' });
// Retrieve data with metadata
const result = await eventbase.get('user123');
console.log(result);
// Output includes data and metadata
API Overview
With Eventbase, you have access to a straightforward API:
createEventbase(config)
: Create a new Eventbase instance with NATS configuration.put(key: string, data: any)
: Store data associated with a key.get(key: string)
: Retrieve data and metadata for a specific key.delete(key: string)
: Remove data from the store.keys(pattern: string)
: List keys matching a specific pattern.subscribe(pattern: string, callback: Function)
: Listen for updates that match the specified patterns, receiving detailed event information.close()
: Safely close the connection and clean up resources.
In-Depth Features
Metadata Tracking
Each item stored includes critical metadata:
- dateCreated: Timestamp of item creation.
- dateModified: Timestamp of last modification.
- changes: Count of updates made to the item.
Pattern Matching Support
Utilize glob-style patterns for flexible data querying:
- Match all user keys with:
user:*
- Target specific orders with:
order:2023:*
Distributed Synchronization
Eventbase ensures that multiple instances of your application can synchronize data automatically and efficiently through NATS JetStream, promoting reliability and scalability.
Eventbase is ideal for developers looking for a robust solution that combines simple key-value storage with powerful real-time capabilities and extensive metadata tracking. Dive into the world of event sourcing and enhance your applications with Eventbase!