New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bun-sqlite-key-value

Package Overview
Dependencies
Maintainers
0
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-sqlite-key-value

A key-value store with SQLite that uses bun:sqlite and v8 as a fast Json replacement.

  • 1.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50
decreased by-32.43%
Maintainers
0
Weekly downloads
 
Created
Source

Bun SQLite Key Value

A key-value store with SQLite that uses bun:sqlite and v8 as a fast JSON replacement.

The ideas for the implementation come from bun-sqlite-cache and bun-kv.

Installation

bun add bun-sqlite-key-value

Usage

Using this key value store is dead simple: simply create a new BunSQLiteKeyValue instance and you're set

import { BunSQLiteKeyValue } from "bun-sqlite-key-value";

const store = new BunSQLiteKeyValue();

store.set("foo", {bar: "baz", waldo: [4, 3, 2, 8]});
const value = store.get("foo");

console.log(value) // { bar: "baz", waldo: [4, 3, 2, 8] }

Documentation

Open Database

const store = new BunSQLiteKeyValue([filename], [options])
  • filename: The full path of the SQLite database to open. Pass an empty string ("") or ":memory:" or undefined for an in-memory database.

  • options: Defaults to {readwrite: true, create: true}. If a number, then it's treated as SQLITE_OPEN_* constant flags.

Example
import { BunSQLiteKeyValue } from "bun-sqlite-key-value";

const store = new BunSQLiteKeyValue();

Write Value

store.set<T=any>(key, value)
  • T can be any data type serializable by v8. Supported data types.

  • key: The key must be a string.

  • value: The value can be any object that can be serialized with v8. This means that not only simple data types such as JSON are possible, but also more complex types such as sets or maps. Here you will find a list of supported data types.

Example
import { BunSQLiteKeyValue } from "bun-sqlite-key-value";

const store = new BunSQLiteKeyValue();
store.set<string>("my-key", "my-value")

Read Value

store.get<T=any>(key)
Example
import { BunSQLiteKeyValue } from "bun-sqlite-key-value";

const store = new BunSQLiteKeyValue();
store.set<string>("my-key", "my-value")

console.log(store.get<string>("my-key"))  // --> "my-value"

Keywords

FAQs

Package last updated on 05 Jul 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc