Index
Prerequisite


Install Mongo database. See Wexler book 13.1.

You do not need to do any pre-setup of any databases. This can be done in the web server code.

Overview


This is a "Getting Started" example that will begin us towards an interactive web app using a database.

In this example we'll define our first database schema (data) and seed it and then show it.

"Seeding" means initializing the database with some data.

Running the Example


To run the example:


Navigating the Example


The example consists of familiar element types: (JS, CSS, HTML).

Example Navigation Tips



Modules


If we are going to start an example from scratch to follow an example we want to know what modules we need.

This is easy to do. We look in "package.json" under "dependencies". Thus we know we would need to do:
npm install ejs express express-ejs-layouts method-override mongoose


Themes


We aim to keep the primary logic in the modeling layer.

Therefore, we will see that the middleware code is lightweight.

Think of "middleware" as between the model and view (or request).

async and await


We're going to utilize our recent study of asynchronous and synchronous to learn two advanced js keywords called async and await.

You will see them commented in "defs-middleware.js" and "".

Building Your Own


To build your own, the best place to start is with "models/def.js". Change that filename and source to suit your own idea -- e.g. movie.js, contact.js, recipe.js, etc as you choose.

Then modify the loader/seeder, middleware, and view for your data.