1.0.7 • Published 4 years ago

@samwen/mongodb-utils v1.0.7

Weekly downloads
18
License
ISC
Repository
github
Last release
4 years ago

mongodb-utils

an useful collection of utils for mongodb operations

how to install

npm install @samwen/mongodb-utils --save

how to use

const { openDatabase, closeDatabase } = require('@samwen/mongodb-utils');
const mongodb_url = 'mongodb://username:password@database.domain.com/database?tls=true';

try {
    const database = await openDatabase(mongodb_url);
    await database.collection('test_collection').insertOne({started_at: Date.now(), key: 'test value'});
} catch(err) {
    console.error(err);
}
await closeDatabase();

note

in order to use mongodb_url in the specified format, you must create user under the database:

mongo shell commands:
use testdb
db.createUser({
    user: "testDbUser",
    pwd: "......",
    roles: [ { role: "readWrite", db: "testdb" } ]
})
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago