sqlite-database
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

sqlite-database

This package builds on sqlite3. It provides a promise-based API for interacting with your sqlite database.

Installation

Install this package with npm:

npm i sqlite-database

Usage

import { SqliteDatabase } from 'sqlite-database';

const db = new SqliteDatabase('path/to/db');

const users = await db.all('SELECT id, name FROM Users');

Add typings to SELECT queries:

const users = await db.all<{ id: number, name: string }>('SELECT id, name FROM Users');  // `users` will be an array of the provided type

Works with both .all and .get.

Query parameters

Use questions marks in your sql query to use variables:

const comment = await db.get('SELECT * FROM Comments WHERE id = ?', [commentId]);

/sqlite-database/

    Package Sidebar

    Install

    npm i sqlite-database

    Weekly Downloads

    281

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    19 kB

    Total Files

    5

    Last publish

    Collaborators

    • diversanto