Enmap is a synchronous, persistent key-value store built on better-sqlite3, designed as a drop-in replacement for JavaScript's Map with additional array methods. Current stable version is 6.1.6, requiring Node >=20. It is TypeScript-compatible and anti-ORM, meaning it can store any serializable data without a predefined schema. Unlike typical databases or ORMs, Enmap provides a simple Map-like API with automatic persistence, making it ideal for beginners and rapid prototyping, especially in Discord bot development. It is actively maintained and synchronous, avoiding callbacks and promises.
npm install enmapVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating an Enmap instance, setting/getting/deleting keys, using reduce method, and closing the database.
Use import syntax (ESM) or downgrade to v5.x for CommonJS support.
Upgrade Node.js to >=20 or use Enmap v5.x.
For large writes, consider batching or using asynchronous alternatives like better-sqlite3 directly.
Use `filter()` or `find()` with caution; prefer `filter()` for multiple matches.
Ensure values are JSON-serializable; use custom serialization if needed.
Switch to import syntax: import Enmap from 'enmap'. Alternatively, downgrade to v5.x.
Use import Enmap from 'enmap' (default import) instead of import { Enmap } from 'enmap'.Ensure you call new Enmap({ name: 'yourname' }) before any operations.