0.4.0 • Published 6 years ago

bookshelf-returning v0.4.0

Weekly downloads
484
License
MIT
Repository
github
Last release
6 years ago

bookshelf-returning

NPM Version Build Status Dependency Status Dev Dependency Status

Bookshelf plugin for PostgreSQL, MSSQL, and Oracle databases that allows for specifying a "returning" clause for insert and update queries. The model is updated with the updated values of the columns specified, giving you an updated representation of your model without needing a subsequent fetch. Delete queries are also supported for returning the state of the model being deleted without requiring it to be fetched first.

Installation

npm install bookshelf-returning --save

Usage

Apply the plugin:

const returning = require('bookshelf-returning');

bookshelf.plugin(returning);

And use returning in your save options:

const User = bookshelf.Model.extend({
  tableName: 'users',
});

User.forge({ id: 1 }).save({ first_name: 'Josh' }, { returning: '*' })
  .then((updated) => {
    console.log(updated.get('first_name')); // Josh
  });
0.4.0

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago