Structuring Data for Persistence

All good apps are built around data. In our case, the data in our app is going to be used to fill in the templates from the previous section. Before we start thinking about how to represent this data in Backbone, we should figure out a reasonable schema for persisting it as JSON on the back end.

We’re going to use a relational schema: the user will have an array of boards, an array of columns, and an array of cards. So a user with one of each entity would have a dataset that looks something like this:

 {
  "boards": [
  {
  "id": 1,
  "name": ​"Pet Tasks"​,
  "columnIds": [1]
  }
  ],
  "columns": [
  {
  "id": 1,
  "name": ​"Dog Tasks"​,
  "cardIds": [1]
  }
  ],
  "cards": [
  {
  "id": 1,
  "description": ...

Get CoffeeScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.