@imtiazchowdhury/mongopool
TypeScript icon, indicating that this package has built-in type declarations

1.5.1 • Public • Published

connect-mongo

Connect to mongoDB and re-use the connection to benefit from mongoDB node driver's connection pooling

    import mongoClient from "@imtiazchowdhury/mongopool"

    //this setup has to be done once only, preferrably in the application root like app.js file
    mongoClient.url = "mongodb://127.0.0.1:27017" // mongodb url
    mongoClient.dbName = "YOUR_DB_NAME"

    ...

    //whenever you need db instance
    const db = await mongoClient.getDB()
    const result = await db.collection("COLLECTION_NAME").findOne({...})

    ...

Installation

npm install @imtiazchowdhury/mongopool

Package Sidebar

Install

npm i @imtiazchowdhury/mongopool

Weekly Downloads

21

Version

1.5.1

License

MIT

Unpacked Size

26.4 kB

Total Files

8

Last publish

Collaborators

  • imtiazchowdhury