Answers for "connect mongo to express api"

1

connect express to mongodb

npm i mongoose

const mongoose = require("mongoose");

mongoose
  .connect(
    "your mongodb URI",
    {
      useNewUrlParser: true,
      useCreateIndex: true,
      useFindAndModify: false,
      useUnifiedTopology: true,
    }
  )
  .then(() => console.log("mongodb connected"))
  .catch((err) => {
    console.log(err.message);
    process.exit(1);
  });
Posted by: Guest on July-19-2021
0

connect mongo to express api

//using mongoose
npm i mongoose

const mongoose = require("mongoose");

mongoose
  .connect(
    "your mongodb URI",
    {
      useNewUrlParser: true,
      useCreateIndex: true,
      useFindAndModify: false,
      useUnifiedTopology: true,
    }
  )
  .then(() => console.log("mongodb connected"))
  .catch((err) => {
    console.err(err.message);
    process.exit(1);
  });
Posted by: Guest on July-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language