connect to to mongoDB

    -1

    2

    lucycodes42

    MERN cookbook

    Library: express

    Shortcut: app.connect

    // required libs : mongoose | colors
    // run the following command
    // npm i mongoose colors
    
    const colors = require('colors');
    const mongoose = require('mongoose')
    mongoose.connect(process.env.URI , { useNewUrlParser : true, useUnifiedTopology : true})
    .then((res)=>console.log('> Connected...'.bgCyan))
    .catch(err=>console.log(`> Error while connecting to mongoDB : ${err.message}`.underline.red ))
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.