$ show bajankristof/nedb-promises
nedb-promises is a lightweight Node.js library that wraps the @seald-io/nedb embedded database (a fork of nedb) with a promise-based API. It provides a Datastore class that extends EventEmitter, offering methods like find, insert, update, remove, and count that return Promises or thenable Cursor objects. The Cursor class supports fluent chaining (sort, skip, limit, project) and can be awaited directly. The library also includes MongoDB-compatible aliases (insertOne, updateMany, deleteOne, etc.) and a static `create()` method that returns a Proxy to access the underlying nedb instance's properties. The codebase is clean, well-tested, and leverages modern JavaScript features (async/await, Proxy, EventEmitter). It is a classic promise wrapper with a thoughtful event system for operation success and error broadcasting.
The LLM identified 1 files worth highlighting for reuse:
The Cursor class wraps the original nedb cursor and implements a thenable pattern (then/catch) while maintaining a fluent API for sort, skip, limit, and project. It demonstrates a clean abstraction for making callback-based cursors promise-compatible, and its pattern (wrapping an internal cursor, delegating methods, and providing exec/then/catch) can be extracted and reused in other projects that need to provide a promise-based cursor interface over a chainable API. The class is self-contained, depending only on the original cursor object passed in, and uses async/await for the exec method with integrated event broadcasting.