Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
uri change
- Loading branch information
1 parent
0413ea5
commit 3b791eb
Showing
1 changed file
with
14 additions
and
12 deletions.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,21 @@ | ||
| import mongoose from "mongoose"; | ||
|
|
||
| let isConnected = false; | ||
| // const uri = "mongodb+srv://Arif:<password>@cluster0.3tw6k.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"; | ||
| const localUri="mongodb://localhost/paste-buckets" | ||
| const uri = "mongodb+srv://Arif:6d4xHrDVMb7BrteV@cluster0.3tw6k.mongodb.net/Arif?retryWrites=true&w=majority"; | ||
| const localuri="mongodb://localhost/paste-buckets" | ||
|
|
||
| export const connect = async () => { | ||
| if (!isConnected) { | ||
| await mongoose.connect( | ||
| localUri, | ||
| { | ||
| useNewUrlParser: true, | ||
| useUnifiedTopology: true, | ||
| useFindAndModify: false, | ||
| useCreateIndex: true, | ||
| } | ||
| ); | ||
| await mongoose.connect(localuri, { | ||
|
|
||
| useNewUrlParser: true, | ||
|
|
||
| useUnifiedTopology: true | ||
|
|
||
| }, err => { | ||
| if(err) throw err; | ||
| console.log('Connected to MongoDB!!!') | ||
| }); | ||
| isConnected = true; | ||
| } | ||
| }; | ||
| }; |