“Mongoose Connect to Atlas” Respostas de código

Conecte o Mongoose ao Atlas

const mongoAtlasUri =
  "mongodb+srv://[email protected]:[email protected]/DB_NAme?retryWrites=true&w=majority";

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");
}
Mystic Dev

Mongoose Connect to MongoDB

// local conecation

const mongoose = require("mongoose");

mongoose
  .connect("mongodb://localhost:27017/testdb")
  .then(() => console.log("Connected to MongoDB..."))
  .catch((err) => console.error("Could not connect to MongoDB...", err));
Average Ant

Mongoose Connect to Atlas

mongoose.connect('mongodb://username:password@host:port/database?options...', {useNewUrlParser: true});
Unusual Unicorn

Respostas semelhantes a “Mongoose Connect to Atlas”

Perguntas semelhantes a “Mongoose Connect to Atlas”

Mais respostas relacionadas para “Mongoose Connect to Atlas” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código