-
Book Overview & Buying
-
Table Of Contents
Socket.IO Cookbook
By :
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.
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 will use Mongoose. This can be installed from NPM by entering npm install mongoose on your terminal.
To send dynamic data from a MongoDB database via Socket.IO, follow these steps:
server.js file. This...
Change the font size
Change margin width
Change background colour