Answers for "node.js connect with mongoose"

8

mongoose connect

import mongoose from 'mongoose'

export const connectDb = async () => {
  try {
    await mongoose.connect('mongodb://localhost:27017/test', {
      useNewUrlParser: true,
      useUnifiedTopology: true,
      useCreateIndex: true,
    })
  } catch (error) {
    console.log(error.message)
  }
}
Posted by: Guest on April-12-2021
1

connecting mongoose with express js

const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test', {useNewUrlParser: true, useUnifiedTopology: true});
Posted by: Guest on May-23-2021

Code answers related to "node.js connect with mongoose"

Browse Popular Code Answers by Language