Here is the code to connect to mongoDB using JavaScript. The C# app in this solution functions.
const MongoClient = require(‘mongodb’).MongoClient;
const uri = "mongodb+srv://mongouser:
@mongodbexample-57u0z.mongodb.net/test?retryWrites=true";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
const collection = client.db("test").collection("devices");
// perform actions on the collection object
client.close();
});
The MongoDB database was created using MongoDB Atlas, which is an application that lets users create databases in the cloud.
Home Page