@iamcalegari/mongoat
v1.0.34-alpha
Published
A ligthweight ODM library for MongoDB
Readme
🚧 This documentation is a work in progress so it may be incomplete or incorrect. If you find any errors or have suggestions, please open an issue.
Mongoat is a fast, extensible, and type-safe ODM (Object Document Mapper) for MongoDB, designed for Node.js environments. It focuses on high performance and flexibility, providing a modern API and advanced extensibility compared to existing solutions.
Table of Contents
Features
- Blazing fast performance
- Simple, intuitive API
- Schema validation and hooks
- TypeScript support
- Easy extensibility
Installation
npm install @iamcalegari/mongoat
yarn add @iamcalegari/mongoat
pnpm add @iamcalegari/mongoatQuick Start
Connecting to MongoDB
import { Database } from '@iamcalegari/mongoat';
const database = new Database({
/**
*
* If you want to connect to a database with a custom name,
* you can set the following property:
*
* dbName: '<MY_DB_NAME>',
*
* Or just set the environment variable:
*
* MONGODB_DB_NAME -> for the database name
*/
dbName: 'mongoat-example',
});
const dbConnection = async () => {
await database.connect();
const info = await database.info();
console.log('Database info: ', info);
await database.disconnect();
};
dbConnection();