1.2.0 • Published 9 months ago

@actvalue/mongo-client v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@actvalue/mongo-client

npm version npm tot downloads npm license

Singleton client for MongoDB connection

Install

npm i @actvalue/mongo-client

Client Usage

The client is used to create and share MongoDB connection pool.

import { mongo } from '@actvalue/mongo-client';

// initialize you connection parameters and optionally set pool size
process.env.MONGO_URL = 'mongo+srv://<your-connection>/database';
process.env.MONGO_POOL_SIZE = "5"; // default value

// create connection pool if not existing already
const db = await mongo.getDb();
const users = db.collection("users");
await users.insertOne({ username: "test123", password: "test123" });

// some other time, some other place in code
// connection pool is reused
const db = await mongo.getDb();
const user = await users.findOne({ username: "test123" });
1.2.0

9 months ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago