Socket
Book a DemoInstallSign in
Socket

anysql

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anysql

Modern minimal API for any SQL database

0.2.1
latest
Source
npmnpm
Version published
Weekly downloads
23
1050%
Maintainers
1
Weekly downloads
 
Created
Source

AnySQL Build Status

Modern minimal API for any SQL database.

Features

  • Unified API for several database engines.
  • No need to manage connections, just query the database.
  • Easy transactions with automatic begin/commit/rollback.
  • Asynchronous functions return promises, feel free to handle them with ES7 async/await feature.

Supported databases

Installation

npm install --save anysql

Usage

Simple query

import AnySQL from 'anysql';

let anysql = new AnySQL('mysql://test@localhost/test');
let rows = await anysql.query('SELECT ? + ? AS solution', [2, 3]);
console.log(rows[0].solution); // => 5

Transactions

import AnySQL from 'anysql';

let anysql = new AnySQL('mysql://test@localhost/test');
await anysql.transaction(async function(transaction) {
  let rows = await transaction.query('SELECT ...');
  // ...
  await transaction.query('UPDATE ...');
  // ...
  // if no error has been thrown, the transaction is automatically committed
});

License

MIT

FAQs

Package last updated on 30 Mar 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.