Skip to content

Instantly share code, notes, and snippets.

@ipiyer
Created January 19, 2016 04:38
Show Gist options
  • Save ipiyer/bb3d6fe6bfbdecb07b75 to your computer and use it in GitHub Desktop.
Save ipiyer/bb3d6fe6bfbdecb07b75 to your computer and use it in GitHub Desktop.
Model methonds
let User = bookshelf.Model.extend({
tableName: 'user',
idAttribute: 'id',
hasTimestamps: ["updated_at", "created_at"],
socialAccount: function() {
return this.hasMany(UserSocialAccount);
},
findById: function(id) {
return this.where({
id: id
}).fetch({
require: true
});
},
findOrCreateUser: function(profile) {
return utils(this).findOrCreateUser(profile);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment