classic-level is an `abstract-level` compliant database implementation backed by LevelDB, serving as the successor to `leveldown`. It offers features such as built-in encodings, sublevels, events, hooks, and first-class support for `Uint8Array`. The current stable version is 3.0.0, with a release cadence that has seen several minor and major updates in the past year, indicating active maintenance. Key differentiators include its adherence to the `abstract-level` interface, providing a consistent API across various Level-family databases, and its direct use of the battle-tested LevelDB C++ library for high performance. It also ships with TypeScript type definitions, making it suitable for modern JavaScript and TypeScript projects. It supports Node.js versions >=18 and Electron >=30, providing prebuilt binaries for common platforms.
npm install classic-levelVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize a `ClassicLevel` database, perform basic `put`, `batch`, `get`, and `iterator` operations, and handle database opening and closing. It uses ESM syntax and includes a cleanup step for repeated execution.
Consult the `UPGRADING.md` guide in the classic-level repository for detailed instructions and potential breaking changes in `abstract-level` v3. Review your database operations and ensure compatibility with the new abstract-level API.
Migrate all database operations to use Promises (e.g., `await db.get(...)`). Handle 'not found' cases by catching the `LevelNotFoundError` (or similar error type, depending on `abstract-level` version) instead of checking for `LEVEL_NOT_FOUND`.
Ensure you have a complete build environment for `node-gyp`, including Python, `make` (or equivalent), and a C/C++ compiler. Refer to the `node-gyp` installation guide. Alternatively, use `npm install classic-level --build-from-source` to explicitly trigger a source build for debugging purposes.
Ensure only one `ClassicLevel` instance attempts to open a database at a given file system location simultaneously. Properly close database instances when they are no longer needed to release the lock. Consider using `db.open()` and `db.close()` within `try...finally` blocks to guarantee cleanup.
Always review the `UPGRADING.md` document for your target version when upgrading `classic-level` or any related `Level` packages to understand breaking changes, new features, and migration paths.
Ensure that no other applications or database instances are accessing the same database location. Verify that previous database instances were properly closed. You might need to manually remove the `LOCK` file if a process crashed and left it behind, but do so with caution.
Update your code to use the Promise-based API for all database operations. For `db.put`, simply `await db.put(key, value)` without a callback.
Install the necessary `node-gyp` dependencies, including Python, `make`/`build-essential` (Linux), Xcode Command Line Tools (macOS), or Visual C++ Build Tools (Windows). Refer to the `node-gyp` GitHub page for detailed installation instructions for your OS.