Slide 49
Slide 49 text
$ = jQuery
Model = require('model')
Collection = require('collection')
PaginatedCollection = require('collection.paginated')
helpers = require('app/helpers')
class Post extends Model
@key 'title', String
@key 'url', String
@key 'user_id', String
@key 'user_handle', String
@url '/v1/posts'
@popular: new PaginatedCollection(
model: this,
all: (model, options = {}) ->
$.post(model.uri('popular'), options.data)
comparator: (a, b) ->
b.get('score') - a.get('score')
)
post.module.coffee