Created Add a collection (markdown)

Scott Erickson 2016-04-22 14:09:11 -07:00
parent 79d48a8ca2
commit 9b7893cff4

24
Add-a-collection.md Normal file

@ -0,0 +1,24 @@
## Problem
You want to add a new collection of data to the site.
## Solution
Define the model's schema, construct REST endpoints on the server, and create a Backbone Model and Collection on the client side to interface with the server for the collection.
## Details
Here are the key things you need to add a collection to the website:
1. JSON schema file in `/app/schemas/models`. This defines what properties of documents in the collection, and is used by both server and client.
1. Mongoose Model in `/server/models`. This is the server's active record interface with MongoDB for the collection.
1. Node/Express REST endpoints in `/server/routes/index.coffee`. Typically need POST, PUT, GET one and GET many, although each collection's may need more or less.
1. Backbone Model in `/app/models`. This is the client's active record interface for a single document in the collection.
1. Backbone Collection in `/app/collections`. This is the client's active record interface for any number of documents in the collection.
## Resources
* [JSON Schema](http://json-schema.org/)
* [Mongoose](http://mongoosejs.com/docs/guide.html)
* [Express](http://expressjs.com/en/3x/api.html)
* [Backbone](http://backbonejs.org/)