qortex-db
v2.2.0
Published
Browser-only Redis-like key-value database with localStorage, sessionStorage, and IndexedDB support
Maintainers
Readme
🗄️ qortex-db
Browser-only Redis-like key-value database. Simple, fast, consistent! 🚀
✨ What makes this special?
qortex-db provides a unified async API across browser storage backends:
- 💾 localStorage - Persists across sessions (default)
- 🔄 sessionStorage - Cleared on tab close
- 📦 IndexedDB - Larger storage capacity
npm install qortex-db🚀 Quick Start
import { createDB } from "qortex-db";
// Simple usage (uses localStorage)
const db = createDB("myapp");
// With options
const db = createDB({ name: "myapp", driver: "indexedDB" });
// Basic operations
await db.set("user:1", { name: "John", age: 30 });
const user = await db.get<User>("user:1");
const exists = await db.has("user:1");
await db.del("user:1");
// Pattern matching
const userKeys = await db.scan("user:*");
const allKeys = await db.scan("*");
// Clear all data
await db.drop();🔋 Unified Persistence
qortex-db provides first-class persistence adapters for the entire Qortex ecosystem. To keep your bundles tiny, these are provided as subpath exports:
qortex-db/query
DB-backed persister for qortex-query.
import { createDB } from "qortex-db";
import { createQueryPersister } from "qortex-db/query";
import { setDefaultConfig } from "qortex-query";
const db = createDB({ name: "myapp", driver: "indexedDB" });
setDefaultConfig({
persister: createQueryPersister(db, { burstKey: "v2" })
});qortex-db/store
DB-backed persister for qortex-store.
import { createDB } from "qortex-db";
import { createStorePersister } from "qortex-db/store";
import { createStore } from "qortex-store";
const db = createDB({ name: "myapp", driver: "indexedDB" });
const store = createStore(
(set) => ({ count: 0 }),
{ persister: createStorePersister(db) }
);[!TIP] Race-Condition Safe: Both persisters automatically wait for the initial async hydration to complete before allowing any writes, preventing data loss.
📖 API
| Method | Description |
|--------|-------------|
| get<T>(key) | Retrieve a value by key |
| set(key, value) | Store a value |
| has(key) | Check if key exists |
| del(key) | Delete a key |
| scan(pattern) | Find keys by pattern (* wildcard) |
| drop() | Delete all data for this database |
🔧 Drivers
| Driver | Persistence | Capacity | Use Case |
|--------|-------------|----------|----------|
| local | Permanent | ~5MB | Default, most common |
| session | Tab session | ~5MB | Temporary data |
| indexedDB | Permanent | Large | Large datasets |
📚 Documentation
Complete documentation available at:
🌐 qortex.darshannaik.com
📄 License
LGPL-3.0 License - see LICENSE file for details.
🎯 Support
- 📚 Documentation: qortex.darshannaik.com
- 📧 Email: darshannaik.com
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 🌟 Repository: https://github.com/Darshan-Naik/qortex
