Storing notes in SQL – SQLite3
To get started with actual databases let's look at using SQL from Node. First we'll use SQLite3, a lightweight, simple-to-set-up, database engine eminently suitable for many applications. To learn about that database engine see http://www.sqlite.org/.
The primary advantage of SQLite3 is it doesn't require a server, but is a self-contained, no-setup-required SQL database.
Setting up a schema with SQLite3
The first step is to make sure our database is configured. We're using this SQL table definition for the schema:
CREATE TABLE IF NOT EXISTS notes ( notekey VARCHAR(255), title VARCHAR(255), author VARCHAR(255), body TEXT );
To set this up we need to run the sqlite3
command. To do so we need to first install the sqlite3
package. For systems with package managers (Linux, MacPorts, and so on) it is probably available as an installable package. Otherwise, source or precompiled binaries are available through the website link given earlier.
Once you...