Socket
Book a DemoInstallSign in
Socket

@slsplus/database

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slsplus/database

Serverless Database Tool

0.0.5
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

Serverless Database Tool

npm NPM downloads Status

Serverless database tool.

Feature

  • Reconnect, it can reconnect automatically after the connection fails
  • Clear Zoombie Connections, it can auto clear the zoombie connections
  • Transaction Rollback, support customize rollback for transaction

Support

Support database dirver:

  • MySQL
  • PostgreSQL

Usage

$ npm i @slsplus/database --save

Use with Mysql

Before you use mysql, you should insall mysql2 dependency:

$ npm i mysql2 --save

Then you can use it as below:

import { Mysql } from '@slsplus/database';

async function example() {
  const db = new Mysql.Database(
    {
      host: 'localhost',
      port: 3306,
      user: 'root',
      password: 'root',
      multipleStatements: true,
    },
    {
      debug: true,
    },
  );

  // insert
  await db.query({
    sql: `
      INSERT INTO users SET ?
    `,
    values: {
      name: 'test',
      email: 'test@test.com',
      site: 'test.com',
    },
  });
  /**
   * return {"fieldCount":0,"affectedRows":1,"insertId":1,"info":"","serverStatus":3,"warningStatus":0}
   */

  // close current connection
  await db.end();
}

Examples

examples

License

MIT License

Copyright (c) 2020 Serverless Plus

Keywords

database

FAQs

Package last updated on 04 Jan 2021

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.