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 🙏

© 2024 – Pkg Stats / Ryan Hefner

glitch-db

v0.17.0

Published

A simple, file based key-value database

Downloads

12

Readme

glitch-db

codecov npm-version

A simple, json file backed, key-value database with support for versioning, audits trails (unitemporal and bitemporal), indices, caching and joins. Supports types via typescript.

Inspired by the music of Glitch Mob

Installation

npm install glitch-db

Getting started

Lets create a simple GlitchDB, insert a few values and read it back. Write your code in a file called code.js

import * as path from "path";
import * as os from "os";
import GlitchDB from "glitch-db";

const gettingStarted = async (): void => {
  // glitch-db will use this directory to store all data and metadata
  const databaseDirectory = "./path/to/db/folder";

  // creates a glitch-db instance with caching enabled by default
  const glitchDB = new GlitchDB(tempDirectory);

  // glitch-db can store one or more types of data
  // for example you could store information about bank accounts,
  // customer details, and loans inside the same glitch-db
  // we refer to these types as "partitions". Lets create one
  const simplePartition = glitchDB.getPartition("simple-key-value");

  // now lets add some data to this partition
  await simplePartition.set("key-1", "value-1");
  await simplePartition.set("key-2", "value-2");
  await simplePartition.set("key-3", "value-3");

  // this is how we access data from a partition
  console.log(await simplePartition.get("key-1")); // value-1

  // to check whether a key exists do this
  console.log(await glitchDB.exists("key-1")); // true

  // you can also update values by setting a new value to the same key, here's how
  await glitchDB.set("key-1", "value-4");
  console.log(await simplePartition.get("key-1")); // value-4

  // to remove a value use the delete api
  await glitchDB.delete("key-3");
  console.log(await glitchDB.exists("key-3")); // undefined

  // you can access all keys inside a parition using the 'keys' api
  console.log(await glitchDB.keys()); // ["key-1", "key-2"]

  // finally you can also look at all data (keys and values) using the 'data' api
  console.log(await glitchDB.data()); // { "key-1": "value-4", "key-2": "value-2" }

  // and that all there is to it!
};

gettingStarted();

Run this file as per instructions below to see glitch-db in action

node code.js

More Examples

Check out test/