Socket
Book a DemoInstallSign in
Socket

@haxtra/kvstore-sqlite

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@haxtra/kvstore-sqlite

Basic key-value store for SQLite databases

0.11.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

kvstore-sqlite

Basic key-value store for SQLite databases.

Install

npm install @haxtra/kvstore-sqlite

Fineprint

  • requires super-sqlite3 or better-sqlite3 instance as the database driver
  • everything is passed through JSON on the way in and out, so:
    • NaN, Infinity become nulls
    • no circular references
    • if data is not JSONable, it will throw

Usage

Create instance

const KVStore = require('@haxtra/kvstore-sqlite')

const kv = new KVStore(superSqlite3Instance, {
    table: 'kvstore'  // table to use for the store, default "kvstore"
})

// when running for the first time, create the table
kv.createTable()

API

Note: All methods are synchronous.

Set/update value

kv.set(keyName, jsonableData)

Retrieve value from the store, falling back to optional default

kv.get(keyName, defaultValue?)

Remove key from the store

kv.delete(keyName)

Check if key exists, returns timestamp of the last update, or false if key is not set

kv.has(keyName)

Get count of stored keys

kv.count()

Get array of stored keys

kv.keys(page?, perPage?)

Get full store data, as an array of objects

kv.data(page?, perPage?)

Remove all data from the store

kv.purge()

Schema

Create table

Create store table with preconfigured name, defaults to kvstore. Returns true on success, false if table exists, throws on invalid table name.

kv.createTable()

Get schema

Get schema definition as a SQL string, with respect to current config.

kv.getSchema()

Schema file

Get absolute path to schema.sql file:

require.resolve('@haxtra/kvstore-sqlite/schema.sql')

License

MIT

Keywords

kvstore

FAQs

Package last updated on 21 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.