Created
November 29, 2020 04:20
-
-
Save mirsahib/7a05c2d16835acbd245eccb9026ba3ad to your computer and use it in GitHub Desktop.
React_Serverless
This file contains hidden or 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
import { MongoClient } from "mongodb"; | |
function createClient() { | |
const client = new MongoClient( | |
`mongodb+srv://admin:${process.env.REACT_APP_DB_PASSWORD}@cluster0.si7bk.mongodb.net/test?retryWrites=true&w=majority`, | |
{ | |
useNewUrlParser: true, | |
useUnifiedTopology: true, | |
}, | |
(err) => { | |
if (err) console.log(err); | |
console.log("Database Connected"); | |
} | |
); | |
client.usersCollection = function () { | |
return this.db("test").collection("users"); | |
}; | |
return client; | |
} | |
export { createClient }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment