Data objects

Ships

The story so far

This course is about making CRUD apps. You know how to do C(reate), and R(ead), and all the appy goodness behind them. Now let's add D(elete). We'll also firm up the way we connect pages.

This lesson is longer than most. Much of it is review. You've already seen how to work with TaffyDB, list data, and add new records. This lesson explains that again, as one last check. Go through the code. You should be able to follow it without much trouble. It will give you confidence that you know what's going on.

Plan to take a break part-way through the lesson.

Dog pack

The story so far

Persisting record sets

There's a problem with the course data app in the previous lesson. It doesn't remember anything. We created a record set when the page loads:

(function($) {
    //Initialize course catalog.
    var catalog = [
        {
            id: 42,
            title: "Web apps for happy dogs",
            maxEnrollment: 40,
            location: "Monty Hall 301"
        },
        ...
    ];

It was lost when the page ended.

We want something like this:

bc.

Course catalog: one course

CRUD web apps deal with structured data, like rows in database tables. We'll be using JS objects for that.

An object is a collection of data and functions. You've already been making objects, without knowing it. You know those namespacing things?

<script>
"use strict";
var CourseScore = CourseScore || {};

CourseScore is a JS object.

JSON

Suppose we want a catalog of university courses. Let's start with one course for now. Here's how you could store information about it:

bc.