Video Pending

Created by Zed A. Shaw Updated 2024-02-15 03:22:43

09: A Fully Dynamic Blog

Your blog would be much better if people could post comments, so you'll use a SQLite3 database to store their comments on each post. You'll also display their comments, and require a login to post.


The "classic" web application style you're creating is called a "Model-View-Controller" (MVC) architecture. The design is separated into:

  1. Models store and manipulate the database, usually stored in a database.
  2. Views present the information to the user and accept their input to alter the models.
  3. Controller is responsible for translating and connecting the Views to the Models and controlling access.

This architecture style is kind of dated, but it is useful when you have a data storage system that is difficult to change, but you still need to present that information to users in different ways. Rather than spend months changing a database's stored procedures you'd simply write a Controller that took existing data and transformed it to match the view.

In your application you'll create a simplified MVC system like this:

  1. Model is a simple module that performs the queries against your database using knex.js to return plain old JavaScript objects (POJOs).
  2. Views that are templates that which accept this data after being converted by controllers.
  3. Controllers are simple handlers in your Express.js application, but if those get too large you should put them into separate modules that you import.
Previous Lesson Next Lesson

Register for Learn JavaScript the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.