Last active
June 16, 2020 12:33
-
-
Save ahmad-ali14/8dd3f8fa92978b50e7417a6a7b80c628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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