simple-connection
v4.1.0
Published
Simple connection wrapper to MongoDB using ES6 modules and ESM
Downloads
69
Readme
Simple Connection -
Description
A utility mongo wrapper connection to simplify the use of the native mongodb driver.
Our legacy description from a 9 year old package
A small implementation to use mongodb with native drives provided by mongodb, but with promises.
Installation
npm install simple-connection
Usage - v4
import SimpleConnection from 'simple-connection';
(async() => {
const db = new SimpleConnection("mongodb://testRoot:testRootSecret@localhost:27017/TEST");
try {
// open database connection
await db.open();
// get collection
collection = await db.collection("collection_test");
} catch() {
console.error("Error connecting to database");
} finally {
// close the connection
db.client.close();
}
})()