$ show couchbaselabs/node-ottoman
Ottoman is a Node.js Object-Document Mapper (ODM) for Couchbase, heavily inspired by Mongoose. It provides a schema-driven modeling layer with type validation, hooks, indexes, and a programmatic N1QL query builder. The library abstracts CRUD operations on Couchbase documents, supports distributed ACID transactions, full-text search, and automatic index management (N1QL, View, and RefDoc indexes). It is designed for production use with TypeScript, includes extensive test coverage against a real Couchbase instance, and offers a CLI for scaffolding. The codebase is well-structured but shows signs of stagnation: the last release (2.5.8) is unpublished, dependencies are outdated (Node >=8, couchbase SDK v4, lodash 4.18.1), and the CHANGELOG has not been updated since early 2022. Despite this, the core architecture is solid and the library remains functional for existing Couchbase projects.
The LLM identified 2 files worth highlighting for reuse:
A generic left-to-right async function composition utility. It takes an initial value and a list of functions, executing them sequentially with the output of each feeding into the next. This is used internally for hook execution but is completely self-contained and could be extracted into any Node.js project needing sequential async transformations.
Defines an enum (KEEP, DROP, THROW, DEFAULT_OR_DROP, DEFAULT_OR_KEEP) and a function to apply a casting strategy when type conversion fails or immutable fields are updated. The logic is isolated and reusable for any data validation or transformation pipeline that needs configurable error handling on type mismatches.