JSPM

sqlite3-promisify

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q33068F
  • License MIT

Promisify all node-sqlite3 functions

Package Exports

  • sqlite3-promisify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sqlite3-promisify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sqlite3-promisify

Build Status

Promisifying node-sqlite3 functions

Install

npm i sqlite3-promisify

Usage

const SQLiteCrud = require('sqlite3-promisify');
const DB_PATH = __dirname + '/sqlite3.db';
const DB_NAME = 'sqlite3_test';

(async () => {
  const Db = new SQLiteCrud(DB_PATH);
  const rows = await Db.all(`SELECT * FROM ${DB_NAME};`);
  console.log(rows);

  ////////// OUTPUT ////////////
  // [ 
  //   { id: 1, name: 'Arshad', email: 'arshadkazmi42@gmail.com' },
  //   { id: 2, name: 'Sqlite3', email: 'sqlite3@db.com' }
  // ]


  const row = await Db.get(`SELECT * FROM ${DB_NAME} WHERE id = ?;`, [1]);
  console.log(row);

  ////////// OUTPUT ////////////
  // { id: 1, name: 'Arshad', email: 'arshadkazmi42@gmail.com' }
  
})();

API

  • connect(path)

    Takes SQLite DB path as input and returns sqlite3 object.

    • Params
      • path (string) - Database absolute path
  • serialize()

    Serialize consecutive db calls.

  • get(query, values={Optional})

    Executes select queries and returns only first result row.

    • Params
      • query (string) - SQL query
      • values (array) - Values for the query
  • all(query, values={Optional})

    Executes any query and returns all the result rows

    • Params
      • query (string) - SQL query
      • values (array) - Values for the query
  • run(query, values={Optional})

    Executes query which does not returns any results

    • Params
      • query (string) - SQL query
      • values (array) - Values for the query
  • close()

    Closes the db connection

Contributing

Interested in contributing to this project? You can log any issues or suggestion related to this library here

Read our contributing guide on getting started with contributing to the codebase

Contributors

Thank you to all the contributors who have helped us in making this project better 🙌