Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mongoose connection nodejs

const mongoose = require('mongoose');

const connectDB = async () => {
    mongoose
        .connect('mongodb://localhost:27017/playground', {
            useCreateIndex: true,
            useNewUrlParser: true,
            useUnifiedTopology: true,
            useFindAndModify: false
        })
        .then(() => console.log('Connected Successfully'))
        .catch((err) => console.error('Not Connected'));
}

module.exports = connectDB;
Comment

mongoose connection

const mongoose = require("mongoose");

//  database connection with mongoose
mongoose.connect("mongodb://localhost/todos", {
        useNewUrlParser: true,
        useUnifiedTopology: true
    })
    .then(() => console.log("connection successful"))
    .catch((err) => console.log(err));
Comment

create new connection in mongoose

const conn = mongoose.createConnection('mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]', options);
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove item from array javascript 
Javascript :: ejs current year 
Javascript :: yarn add next auth 
Javascript :: GET http://localhost:8000/js/app.js net::ERR_ABORTED 404 (Not Found) in laravel 6 
Javascript :: us postal code regex 
Javascript :: js add multiple element to document 
Javascript :: Object of type * is not JSON serializable 
Javascript :: onclick arrow function javascript 
Javascript :: async function 
Javascript :: how to generate random color hexcodes for javascript 
Javascript :: javascript remove object from array 
Javascript :: stopwatch with javascript 
Javascript :: reactjs firebase timestamp to date 
Javascript :: TypeError: Object of type ndarray is not JSON serializable 
Javascript :: reset select2 jquery | clear select2 option value 
Javascript :: xlsx to json using xlsx react 
Javascript :: json array in hidden field not coming 
Javascript :: darkmode js 
Javascript :: nodejs add new property array object 
Javascript :: pdf to json online 
Javascript :: Duplicate empty header occur in datatable when enabling scrollX or scrollY when using Google Chrome 
Javascript :: yup string date schema validation 
Javascript :: set selected option jquery 
Javascript :: load youtube iframe player api 
Javascript :: see all set variables chrome 
Javascript :: handle onchange react 
Javascript :: logical operators in js 
Javascript :: why can i put comments in some json files 
Javascript :: regx to accept name 
Javascript :: javascript get character from string 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =