Loading data from MongoDB

As we are now able to send static data to our client with Socket.IO, we have all the tools we need to send dynamic data as well. MongoDB is a NoSQL database that stores data as JSON documents. In this recipe, we will send data from our database to the client side to get rendered.

Getting ready

Before you begin, you will need to install MongoDB on your machine. MongoDB can be installed by navigating to https://www.mongodb.org and following the installation steps there. Once MongoDB is installed, you can start the MongoDB server by entering mongod on your terminal window. Leave the mongod process running; you'll need to have it available to access your database.

You will also have to install a Node adapter for MongoDB. We ...

Get Socket.IO Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.