npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sqlite-table

v0.9.0

Published

SQLiteTable class for sqlite3 module

Readme

SQLiteTable

SQLiteTable is a class that helps you deal with sqlite database. It's very simple and useful for small projects when you don't want any kind of ORM but also you don't wont to find yourself in writing simple queries over and over again.

SQLiteTable is written in TypeScript and it provides typings if you would like to use it with this language (which is recommended) hovewer you can use SQLiteTable with plain JavaScript also.

SQLiteTable is designed in OOP manner and it's best to inherit from it.

Installation

npm install sqlite-table

Example usage

var SQLiteTable = require('sqlite-table');
var sqlite3 = require('sqlite3');

// UserTable class:
var UserTable = function (db) {
  SQLiteTable.call(this, db);
  this.tableName = 'user';
};
UserTable.prototype = Object.create(SQLiteTable.prototype);

// example usage
var db = new sqlite3.Database(':memory:');
db.run('CREATE TABLE user(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT)', function (err) {
  var userTable = new UserTable(db);
  var user = {firstName: 'Szymon',lastName: 'Wygnański'};
  user.insert(user, function (err) {
    if (err) {
      // do something with the error
    } else {
      console.log(user); // => {id: 1, firstName: 'Szymon',lastName: 'Wygnański'};
    }
  });
});

API

get many records

public all(next:(err:Error, result:any[])=>void):void;
public all(params?:any, next?:(err:Error, result:any[])=>void):void;

You can get many records using all method. If you will not specify param object then you will get all the records.

You can specify params object and set the search criteria. For example:

var db = new sqlite3.Database(':memory:');
var userTable = new UserTable(db);

userTable.all({firstName: 'Szymon'}, function (err, users) {
  /// users is an array of all the users with first name Szymon.
});

limited get many records

public allLimited(where?:any,
                  limit:{limit:number;offset:number} = {limit: 1000, offset: 0},
                  next:(err?:Error, result?:any[])=>void = ()=> {}):void;
var db = new sqlite3.Database(':memory:');
var userTable = new UserTable(db);

userTable.allLimited({firstName: 'Szymon'}, {limit: 3, offset: 2}, function (err, users) {
  /// users is an array of all the users with first name Szymon.
});

count

public count(where:any = {}, next:(err?:Error, count?:number)=>void = ()=>{}):void;

save

public save(data:any, next:(err?:Error, record?:any)=>void):void;

if data.id is set then update method is invoked, otherwise insert. next callback receive the saved record as a recult.

get one record

public find(params:string, next:(err:Error, result:any)=>void):void;
public find(params:any, next:(err:Error, result:any)=>void):void;

Works same as all method but returns only one record.

insert

public insert(data:any, next:(err?:Error, id?:string)=>void):void;

Insert data into database. Second param of the next callback function will be an id of the new record and data.id property will be set.

update

public update(data:any, next:(err?:Error)=>void):void;

Update record by data.id. The field: data.id must be set, otherwise an error is thrown.

remove

public remove(id:string, next:(err?:Error)=>void):void;

Removes record by id.

Joins

If you want to do something with the record before retrieving it by find or all methods then you can implement the joins(record:any, done:(err:Error, record?:any)=>void):void method.

LICENSE: ISC

ISC license is even simpler MIT like license. Check out the LICENSE file.