mongoose atlas code example

Example 1: mongoose connect to URL of atlas

try {
  mongoose.connect(MONGODB_URI || 'mongodb://localhost/YOUR_DB_NAME', {
      useNewUrlParser: true,
      useUnifiedTopology: true
    }, () =>
    console.log("connected"));
} catch (error) {
  console.log("could not connect");
}

Example 2: mongodb atlas node js mongoose

try {
    // Connect to the MongoDB cluster
     mongoose.connect(
      mongoAtlasUri,
      { useNewUrlParser: true, useUnifiedTopology: true },
      () => console.log(" Mongoose is connected")
    );

  } catch (e) {
    console.log("could not connect");
  }

Example 3: what is mongodb atlas

MongoDB Atlas is the global cloud database service for modern
applications.

Deploy fully managed MongoDB across AWS, Azure, or GCP.

Best-in-class automation and proven practices guarantee availability,
scalability, and compliance with the most demanding data security and
privacy standards.

Use MongoDB's robust ecosystem of drivers, integrations, and tools
to build faster and spend less time managing your database.