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

lib-websql

v0.1.1

Published

Web SQL library for use in the browser/electron/nwjs.

Readme

lib-websql

This is a Web SQL library for use in the browser. Very useful in Electron and NW.js Apps, things that require complex queries. I know Web SQL is deprecated, but browsers have not yet announces it's removal so I am hoping it will stick around a long time or until they replace it with a relational database. It also might be worth checking out some alternatives like RxDB, PouchDB, LinvoDB, NeDB or sql.js.

This library is written with ES7 async await so using a browser that supports it is key.

Note: When using await you must used this library inside an async function. It is recommended having a decent amount of knowledge on SQLite3 which is what WebSQL is using in-browser.

Usage

Initialize

async function init() {
	const WebSQl = require('./websql')
	const websql = new WebSQl(options)
	await websql.connect(options)
}

Options (all optional)

  • db database name
  • description database description
  • version database version
  • size (2 * 1024 * 1024)

Create a Table

let fields = [
	websql.field({name: 'id', type: 'integer', index: 'PRIMARY KEY'}),
	websql.field({name: 'idArtist', type: 'integer'}),
	websql.field({name: 'title', type: 'integer'}),
	websql.field({name: 'description', type: 'varchar', length: 255, default: ''}),
	websql.field({name: 'entered', type: 'integer'}),
	websql.field({name: 'updated', type: 'integer'})
]
let results = await websql.tableCreate('album', fields, true)

Note Read more about field types below.

Note The 3rd parameter is a boolean if you want to use IF NOT EXISTS.

MISC

List Tables

let tables = await websql.tables()

Check if Table Exists

let bool = await websql.tableExists('album')

List Table Fields

let fields = await websql.tableFields('album')

Drop a Table

await tableDrop('album')

Field Object

When creating tables or listing fields the field object is always used. It consists of the following properties:

  • name Field/Column Name
  • type Column Type (See Below)
  • length Size of Type
  • null If Column Can Be Null
  • index If the field is indexed UNIQUE, PRIMARY KEY, KEY
  • ai If the integer is Auto Increment

(SQLite3) Column Types:

BLOB, BOOL, CLOB, FLOAT, INTEGER, NUMERIC, REAL, VARCHAR, NVCHAR, TEXT

Inserting

const now = Math.floor(new Date().getTime() / 1000)
const idAlbum = await websql.insert('album', {
	idArtist: 1,
	title: 'Cows and Chickens',
	description: 'This is really great!',
	entered: now,
	updated: now
}, false)

Note The 3rd parameter is a boolean if you want to use IGNORE.

Updating

await websql.update('album', 1, {
	updated: Math.floor(new Date().getTime() / 1000)
})

Fetching a Record

const record = await websql.fetch('album', {id: 2})

Fetching Multiple Records

const record = await websql.select('album', {idArtist: 1})

Running a Query With Results

let query = 'SELECT * FROM ' + websql.escapeField(table) + ' WHERE id > ?'
let values = [20]
var results = await websql.query(query, values, true)
for(var i = 0; i < results.row.length; i++)
	console.log('row', i, results.rows.item(i))

Note The 3rd parameter is a boolean if you want processed results, false will return a SQLite results object.

Deleting Rows

await websql.delete('album', {id: 1})

To Do

  • Where Operators
  • Table Structure Sync