class Book extends Bookshelf.Model
tableName: 'books'
class Book extends Bookshelf.Model
# Associations
author: -> @belongsTo(Author)
summary: -> @hasOne(Summary)
pages: -> @hasMany(Pages)
shelves: -> @belongsToMany(Shelves)
@hasMany(Comment)
.through(Chapter)
@belongsToMany(Comment)
.withPivot(['created_at'])
class Books extends Bookshelf.Collection
model: Book
books = new Books()
books.query(where: { id: 2 })
.fetch()
.then ->
new Book(id: 1).summary().fetch()
.then (summary) ->
new Story(id: 2).fetch()
.then (story) ->
story.id #=> 2
story.title #=> "Through the Looking Glass"
story.summary = "Hello"
story.save()
.then -> ...