Skip to content

Instantly share code, notes, and snippets.

@ahmad-ali14
Last active June 16, 2020 12:33
Show Gist options
  • Save ahmad-ali14/8dd3f8fa92978b50e7417a6a7b80c628 to your computer and use it in GitHub Desktop.
Save ahmad-ali14/8dd3f8fa92978b50e7417a6a7b80c628 to your computer and use it in GitHub Desktop.
//DB and authentication
mongo.connect(process.env.DATABASE_URL, (err, cluster) => {
if(err) {
console.log('Database error: ' + err);
} else {
// 1- connecting to the cluster
console.log('Successful database connection');
// 2- connetcing to the database
const db = cluster.db(DATABASE_NAME);
// 3- conneting to the collection
const coll = db.collection(COLLECTION_NAME);
//do your stuff on the collection here.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment