New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rosen-bridge/atomic-typeorm-create-query-runner

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rosen-bridge/atomic-typeorm-create-query-runner

An alternative to default typeorm's createQueryRunner which behaves atomic and supports parallel transactions for sqlite

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

@rosen-bridge/atomic-typeorm-create-query-runner

Table of contents

  • Introduction
  • Installation
  • Usage

Introduction

By default, typeorm doesn't handle parallel transactions. If you run two transactions simultaneously and your database doesn't support it (e.g. if you use sqlite), you will get errors.

Installation

npm:

npm i @rosen-bridge/atomic-typeorm-create-query-runner

yarn:

yarn add @rosen-bridge/atomic-typeorm-create-query-runner

Usage

import createAtomicQueryRunner from '@rosen-bridge/atomic-typeorm-create-query-runner';

const foo = () => {
  // const queryRunner = dataSource.createQueryRunner();
  const queryRunner = createAtomicQueryRunner(dataSource);

  await queryRunner.connect();
  await queryRunner.startTransaction();

  try {
    await applyAtomicQuery();
    await queryRunner.commitTransaction();
  } catch {
    await queryRunner.rollbackTransaction();
  } finally {
    await queryRunner.release();
  }
};

// You can now call the transactions simultaneously without getting errors
foo();
foo();

As you can see, no big changes required to use the package.

Keywords

FAQs

Package last updated on 20 Mar 2023

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc