@am92/mongo-odm
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

@am92/mongo-odm

npm version  ECMAScript Module  License: MIT  Vulnerabilities: Snyk  Downloads Bundle Size


This is an ODM (Object Document Mapping) which provides CRUD functionalities to interact with MongoDB Collections. This package uses mongoose package using its 8.4.1 version.

This package provides the following functionalities:

  • MongoDB Connection Helper
  • Mongoose Schema Wrapper
  • Collection Modeling Class

Table of Content


Installation

npm install --save @am92/mongo-odm

Environment Variables

The following environment variables need to be set to work with this package:

##### Mongo Config
export MONGO_HOSTS=
export MONGO_DBNAME=
export MONGO_USER_AUTH=false
export MONGO_USERNAME=
export MONGO_PASSWORD=
export MONGO_REPLICASET=
export MONGO_REPLICASET_COUNT=0
export MONGO_READ_PREFERENCE=
export MONGO_SSL_ENABLED=false
export MONGO_SSL_VALIDATE=false
export MONGO_PEM_PATH=
export MONGO_MIN_POOL_SIZE=0
export MONGO_MAX_POOL_SIZE=100

Note: Do not export variable 'MONGO_READ_PREFERENCE' if no value is to be set.


Connecting to MongoDB

MongoDB needs to be connected before the 'Model' methods can executed. The connection can be established as shown below:

import { mongoConnect } from '@am92/mongo-odm'
await mongoConnect()

Contributors

Ankit Gandhi
Ankit Gandhi
Mehul Agarwal
Mehul Agarwal

Resources


License



Package Sidebar

Install

npm i @am92/mongo-odm

Weekly Downloads

66

Version

2.0.7

License

MIT

Unpacked Size

76.9 kB

Total Files

23

Last publish

Collaborators

  • ankitgandhi452
  • agarwalmehul
  • heliumtank92