You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The update method can now be used on all your models.
Example
/** * Save new user 'ernie' to database. * Since the user isNew(), the update function * will perform a full insert operation. */newUser({username: 'ernie',password: 'meepmoop',}).update().then(usr=>console.dir(usr)).catch(err=>console.log(err));/** * Get user 'ernie', and update its password to 'meepmeep'. * Only the password field is updated and on second attempt no * update query is run. */User.where({username: 'ernie'}).fetch().then(usr=>usr.set('password','meepmeep')).then(usr=>usr.update()).then(usr=>console.dir(usr)).catch(err=>console.log(err));});/** * When creating a user with the ID already specified * you might need to force an insert like so: */newUser({id: '11',username: 'ernie',password: 'meepmoop',}).update({forceInsert: true}).then(usr=>console.dir(usr)).catch(err=>console.log(err));
Working
This is a simple wrapper around model.save(model.changed, {patch: true});.
About
Simple bookshelf plugin that allows simple patching of models and skips updating if no values have changed.