MongoDB on Cloud with Node.js
Create Database Mongo Db , Connect Mongo with node.js. FREE
register in web site https://www.mongodb.org/
After you registered . LOGIN at https://account.mongodb.com/account/login
Waiting your cluster be create .
Now The project has been created. and then we setting security network access .
In this time you can add current IP address or allow access from anywhere.
Waiting Until the status becomes Active.
And then . We Create new database user .
Insert your Username password and Click Create Database User .
Next step we choose Choose connection method. In this time we use Node js with mongo DB
Connect to Cluster0
Next step we create project node js
In windows . Create Folder and enter in folder and run cmd npm init.
and Enter until installation is complete.
In this Example we use Visual studio Code for development.
Create file database.js
Enter code for connect node js with mongo db. and paste connection string from Connect to Cluster0
run file database.js in terminal
If your found Error: Cannot find module ‘mongoose
Enter cmd : npm install mongoose
And rum cmd : node database.js again.
Connected Mongo with node.js .
Reference
Book : พัฒนาเว็บเเอพลิเคชันด้วย Node.js Express+MongoDB จีราวุธ วารินทร์
Thank you.