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.
Common errors
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.
Warnings
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.
Install
npm install camo yarn add camo pnpm add camo Imports
- connect wrong
const connect = require('camo').connectcorrectimport { connect } from 'camo' - Document wrong
const Document = require('camo').Documentcorrectimport { Document } from 'camo' - EmbeddedDocument wrong
import EmbeddedDocument from 'camo'correctimport { EmbeddedDocument } from 'camo'
Quickstart
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);