From 9e80ec9f40a7dfd397e82a15120ab40f403974fd Mon Sep 17 00:00:00 2001 From: Amit Kumar <41584018+4m17-c9der@users.noreply.github.com> Date: Thu, 10 Nov 2022 12:03:09 +0530 Subject: [PATCH 1/2] Update template.js Easier This way --- template.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/template.js b/template.js index 2785d10..8da6c3d 100644 --- a/template.js +++ b/template.js @@ -1,11 +1,14 @@ const { MongoClient } = require('mongodb'); +const username = encodeURIComponent("userName"); +const password = encodeURIComponent("password"); + async function main() { /** * Connection URI. Update , , and to reflect your cluster. * See https://docs.mongodb.com/drivers/node/ for more details */ - const uri = "mongodb+srv://:@/sample_airbnb?retryWrites=true&w=majority"; + const uri =`mongodb+srv://${username}:${password}@${cluster}/?retryWrites=true&w=majority`; /** * The Mongo Client you will use to interact with your database From cdbbc54a0a81fefecb21813bf64a47940cab3c70 Mon Sep 17 00:00:00 2001 From: Amit Kumar <41584018+4m17-c9der@users.noreply.github.com> Date: Thu, 10 Nov 2022 18:17:27 +0530 Subject: [PATCH 2/2] Correction to :- Cluster is not defined ! --- template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.js b/template.js index 8da6c3d..a5decbd 100644 --- a/template.js +++ b/template.js @@ -2,7 +2,7 @@ const { MongoClient } = require('mongodb'); const username = encodeURIComponent("userName"); const password = encodeURIComponent("password"); - +const cluster = "your-cluster-url"; async function main() { /** * Connection URI. Update , , and to reflect your cluster.