Using a database
We've successfully moved our application's data to an encapsulated endpoint, which is great. Now that we've done that, we can start thinking about making that data dynamic. Right now it's stored in a static code file. This is fine when none of the data needs to change, but if we want our application to be interactive, we'll need a way to work with the data. It's time to use a database.
There are many powerful database solutions available, from SQL options such as MySQL and Postgres, to a newer breed of NoSQL engines such as MongoDB and CouchDB, plus simple key-value stores such as Redis and Riak. Almost all popular database engines have drivers available for Node. However, we're going to use a simpler option. We'll be using a database named nStore, which is written entirely in JavaScript and uses a simple file store. This means we won't need to fuss with installing extra software, running services, and compiling drivers. Instead, we can install a simple Node module and focus...