MongoDB on Cloud with Node.js

Create Database Mongo Db , Connect Mongo with node.js. FREE

register in web site https://www.mongodb.org/

click Try Free
Register and Get started free.

After you registered . LOGIN at https://account.mongodb.com/account/login

Login mongo
New Project
Insert your Project name and Next.
Build a cluster.
Continue.
Choose left for free Trial.
Choose Singapore and click Create cluster.

Waiting your cluster be create .

cluster be created.

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

Copy string connection config.

Next step we create project node js

In windows . Create Folder and enter in folder and run cmd npm init.

create folder hellomongo
go to your folder . in this time folder name is hellomongo
Create project node js

and Enter until installation is complete.

Open your project.

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.

#full stack developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store