Socket
Book a DemoInstallSign in
Socket

bookshelf-cls-transaction

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-cls-transaction

A bookshelf plugin that uses continuation-local-storage to store transactions into call stack context. So you don't need to pass transaction into every method, that must be under transaction. This plugin does this automatically.

latest
Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
3
-25%
Maintainers
1
Weekly downloads
 
Created
Source

bookshelf-cls-transaction

A bookshelf plugin that uses continuation-local-storage to store transactions into call stack context. So you don't need to pass transaction into every method, that must be under transaction. This plugin does this automatically.

Examples

Without this plugin:

const user = await bookshelf.transaction(async (trx) => {
  const club = await new Club({ name: 'The Foos' })
    .save(null, { transacting: trx });
  const user = await new User({ name: 'Sam', club_id: club.id })
    .save(null, { transacting: trx });
  return user;
});

With this plugin:

const user = await bookshelf.transaction(async () => {
  const club = await new Club({ name: 'The Foos' }).save();
  const user = await new User({ name: 'Sam', club_id: club.id }).save();
  return user;
});

Installation

Install with npm:

npm i bookshelf-cls-transaction

Add plugin to your bookshelf:

bookshelf.plugin(require('bookshelf-cls-transaction'));

Keywords

bookshelf

FAQs

Package last updated on 12 Oct 2017

Did you know?

Socket

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