CJCoding With Joseph
15free / daySign inCreate account

NodeJs

Saving messages to MongoDB

Connecting To MongoDB

Up until now, your project has been saving form data inside a JSON file. This was perfect for learning the basics of server requests, routing, and storing information. But in real web development, almost every website or app needs a real database so it can safely store and retrieve data even as the project grows.

This is where MongoDB comes in. It works perfectly with JavaScript and Node because it stores data in a format that looks almost exactly like JSON.


What MongoDB Is

MongoDB is a NoSQL document database. That means

• It does not use tables like MySQL or a relation database
• It does not require strict structure
• It stores data inside collections instead of tables
• Each piece of data inside a collection is a document
• Documents look just like JSON objects

Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 8 more lessons in NodeJs.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.