WHAT’S IN THIS CHAPTER?
As in many other programming environments, you will sooner or later want to persist certain types of data your application generates. This is especially true with multi-user server-client applications, in which information one user provides needs to be presented to one or many other users at a later point in time.
Although saving data in flat files or memory works in Node just as well as in other environments, it doesn’t scale when structured access is needed for large amounts of data.
Relational databases like MySQL provide a reliable and fast solution to save and retrieve information in a structured manner by storing data on the hard drive and making it accessible through the standardized SQL language.
If your Node applications need to be able to communicate with MySQL databases and exchange data with them, the following sections on using the node-mysql library, reading from a MySQL database efficiently, and passing in data in a secure way will enable you to accomplish these tasks.
As installing and setting up a MySQL database is not within the scope of this book, it’s assumed that you have a working MySQL instance running on your localhost or on another reachable host. ...