This is Devhints.io cheatsheets — a collection of cheatsheets I've written.

# Bookshelf.js

## Model

    Summary = bookshelf.Model.extend({
      tableName: 'summaries',
      hasTimestamps: true,
      hasTimestamps: ['created_at', 'updated_at'],
    })

### Associations

    Summary = bookshelf.Model.extend({
      book () {
        return this.belongsTo(Book)
      },
      author () {
        return this.hasOne(Author)
      }
      // belongsToMany
      // hasMany
      // hasMany().through()
    })

### CRUD

    Book.create({ title: '..' }).save()
    new Book({ title: '..' }).save()

    new Book({ id: 1 }).fetch()

    Book.where({ id: 1 }).fetch()
    Book.where('favorite_color', 'red').fetch()
    Book.where('favorite_color', '<>', 'red').fetch()
    Book
      .query((q) => q.orderBy('updated_at')

Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. Suggestions and corrections? Send them in. I'm Rico Sta. Cruz. Check out my Today I learned blog for more.