Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mongodb nodejs connect localhost

"mongodb://localhost:27017/MyDb"
Comment

connect to mongodb nodejs

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);
Comment

connect to local mongodb node

Connect to local mongodb
Comment

PREVIOUS NEXT
Code Example
Javascript :: json data find 
Javascript :: javascript centuries 
Javascript :: ios ad mobs 
Javascript :: vite esbuild configuration 
Javascript :: trim angular material input with ellipsis 
Javascript :: filewatcher nodejs 
Javascript :: kube allow pod deployment on master node 
Javascript :: animejs code sample for keyframe property 
Javascript :: Arrow Function Shorthand javascript 
Javascript :: Bitwise IndexOf Shorthand in javascript 
Javascript :: react controllers 
Javascript :: load widget after read data from json file 
Javascript :: making a react js website project ready for hosting 
Javascript :: javascript variable without value 
Javascript :: How display console log in frontend 
Javascript :: how to route with credentials react 
Javascript :: slice method javascript 
Javascript :: execute shell command from html button node js 
Javascript :: fiffo in javascript 
Javascript :: acc&egrave;der data-id javascript 
Javascript :: strapi extend user model 
Javascript :: nodejs post req accept form data 
Javascript :: sails commands 
Javascript :: material ui refresh icon 
Javascript :: get data form and map in react js 
Javascript :: Default function arguments in ES6 
Javascript :: format file using jq input curl 
Javascript :: multiple counter for loop in javascript 
Javascript :: Show / Hide Div On Radio Button Click angular 
Javascript :: how to get nth tr in js 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =