Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hscheuerle
Last active May 25, 2019 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hscheuerle/0692b0636165a37cba5dff32f3bb3b17 to your computer and use it in GitHub Desktop.
Save hscheuerle/0692b0636165a37cba5dff32f3bb3b17 to your computer and use it in GitHub Desktop.
Naming for mongodb driver
const { MongoClient: driver } = require('mongodb');
const connectionSpread = [
process.env.DB_URL_DEVELOPMENT || 'mongodb://localhost:27017',
{ useNewUrlParser: true }
];
(async () => {
try {
const client = await driver.connect(...connectionSpread);
const mongo = client.db('test').collection('some-objects');
const { result } = await mongo.insertOne({ test: "test" });
} catch (reason) {
console.log(reason);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment