Camo

raw JSON →
0.12.5 verified Fri May 01 auth: no javascript maintenance

A class-based ES6 ODM (Object Document Mapper) for Mongo-like databases (currently supports MongoDB and NeDB). Current stable version is 0.12.5, last updated in 2019. The project has low release cadence and is mostly in maintenance mode. Key differentiators: it enforces ES6 classes for schema definition, supports multiple backends including the embedded NeDB (like SQLite for MongoDB), and uses native Promises. Alternatives: Mongoose (more popular and actively maintained) or NeDB directly. Not recommended for new projects due to lack of maintenance.

error Error: Must call connect() before performing any operations
cause Database connection not established before document operations.
fix
Add await connect() before using any Document methods.
error TypeError: Class extends value undefined is not a constructor or null
cause Failed to import Document properly (e.g., default import instead of named).
fix
Use import { Document } from 'camo'.
error MongoError: Authentication failed
cause Invalid credentials provided to connect().
fix
Check username/password in connection string.
deprecated Project is unmaintained since 2019. No updates for security or compatibility.
fix Consider migrating to Mongoose or NeDB directly.
gotcha NeDB backend is not thread-safe and not recommended for production.
fix Use MongoDB backend for production.
gotcha The connect() function must be called before any document operations, but it's not enforced at type level.
fix Always await connect() at the start of your application.
breaking ES6 classes require Node >= 4 and a transpiler for older environments.
fix Use Node >= 4 or transpile with Babel.
npm install camo
yarn add camo
pnpm add camo

Shows connecting to a database, defining a Document subclass, creating/saving a document, and querying.

import { connect, Document } from 'camo';

// Define a document schema
class User extends Document {
  constructor() {
    super();
    this.name = String;
    this.age = Number;
    this.email = { type: String, unique: true };
  }
}

async function main() {
  const db = await connect('mongodb://localhost:27017/mydb');
  // Alternatively for NeDB: await connect('nedb://path/to/db');

  const user = User.create({ name: 'Alice', age: 30, email: 'alice@example.com' });
  await user.save();
  console.log('User saved:', user._id);

  const users = await User.find({ age: { $gte: 18 } });
  console.log('Users:', users);

  await db.close();
}

main().catch(console.error);