Lam Posted on May 14, 2021 2 2 Bookshelf.Js Cheat Sheet #bookshelfjs #cheatsheet 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') Enter fullscreen mode Exit fullscreen mode Associations Summary = bookshelf.Model.extend({ book () { return this.belongsTo(Book) }, author () { return this.hasOne(Author) } // belongsToMany // hasMany // hasMany().through() }) Enter fullscreen mode Exit fullscreen mode Reference Bookshelf.Js Cheat Sheet - Cheat Sheet Maker Top comments (0) Subscribe Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)