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

@bitfinex/bfx-facs-db-sqlite

v1.0.0

Published

Bitfinex DB Sqlite Facility

Readme

bfx-facs-db-sqlite

API

fac.upsert

Returns { lastID: <lastID> } in the result

Example:

fac.upsert({
  table: 'Employees',
  selectKey: 'id',
  selectValue: '1',
  data: { id: 1, name: 'paolo', surname: 'ardoino' }
}, cb)

// runs:
d.run(
  "INSERT OR REPLACE INTO Employees (id, name, surname) VALUES ((SELECT id FROM Employees WHERE id = $id),  $name,  $surname)",
  { '$id': '1', '$name': 'peter', '$surname': 'bitcoin' }
)

fac.cupsert

Provides a simple way to check and process data before an upsert.

Example:

fac.cupsert({
  table: 'Employees',
  selectKey: 'id',
  selectValue: '1',
  process: (data, cb) => {
    data[0].surname = 'diaz'
    cb(null, data[0])
  }
}, cb)

fac.runMigrations

  • migrations: <Array>
    • inex 0..x: <Function>
  • cb: <Function>

Runs an array of functions (migrations).

Each function in the migrations array is passed the faculty instance and a callback.

Assumptions:

  1. PRAGMA user_version will be used to track migrations. It is assumed to unused and will increment as an id for the index of the migrations array
  2. New migrations will always be added to the end of the migrations array and old migrations shall never be deleted from the array. The PRAGMA user_version will track which migrations in the migration array which have run and only run new migrations.
  3. Each migration is automatically wrapped in a TRANSACTION. Migrations will stop running on any error.

Example Migrations

// api.my.wrk.js
  init () {
    super.init()

    this.setInitFacs([
      ['fac', 'bfx-facs-db-sqlite', 'main', 'main', {
        name: this.prefix,
        persist: true
      }]
    ])

  }

  _start (cb) {
    const migrations = [
      (dsm, cb) => {
        dsm.db.run('ALTER TABLE token_sales ADD COLUMN listed INTEGER;', cb)
      }
    ]

    async.series([
      next => { super._start(next) },
      next => { this.dbSqlite_main.runMigrations(migrations, next) }
    ], cb)
  }

Config

name

Used to construct the database name: sqlite_$NAME_$LABEL.db

label

Used to construct the database name: sqlite_$NAME_$LABEL.db

runSqlAtStart

Runs SQLite commands at start of the service. Useful to create a table if it does not exist. Takes an array commands to run.

Example fields:

{
  "runSqlAtStart": [
    'CREATE TABLE IF NOT EXISTS vegetables (id INTEGER PRIMARY KEY ASC, sold, price)',
    'CREATE TABLE IF NOT EXISTS meat (id INTEGER PRIMARY KEY ASC, sold, price)'
  ]
}