Answers for "connect to mongodb"

17

mongodb local connection string

mongodb://localhost:27017/mydbname
Posted by: Guest on May-28-2020
3

connect to mongo database

mongoose.connect(mongoURI);
Posted by: Guest on January-14-2021
1

how to connect mongodb with node js

async function main(){
    /**
     * Connection URI. Update <username>, <password>, and <your-cluster-url> to reflect your cluster.
     * See https://docs.mongodb.com/ecosystem/drivers/node/ for more details
     */
    const uri = "mongodb+srv://<username>:<password>@<your-cluster-url>/test?retryWrites=true&w=majority";
 

    const client = new MongoClient(uri);
 
    try {
        // Connect to the MongoDB cluster
        await client.connect();
 
        // Make the appropriate DB calls
        await  listDatabases(client);
 
    } catch (e) {
        console.error(e);
    } finally {
        await client.close();
    }
}

main().catch(console.error);
Posted by: Guest on July-23-2020
0

connect to mongodb

npm install mongodb --save
Posted by: Guest on February-03-2021
0

connect to mongodb

const MongoClient = require('mongodb').MongoClient
Posted by: Guest on February-03-2021

Browse Popular Code Answers by Language