Socket
Socket
Sign inDemoInstall

bookshelf-returning

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bookshelf-returning

Bookshelf plugin for adding returning clause to insert/update queries


Version published
Maintainers
1
Install size
1.96 MB
Created

Readme

Source

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
  });

Keywords

FAQs

Last updated on 09 Mar 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc