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

ice-db

v1.2.2

Published

In-memory DB

Downloads

4

Readme

IceDB

npm npm NpmLicense David npm bundle size (minified)

IceDB is a tiny and fast in-memory database for NodeJS

Setup

  1. Run npm i -s ice-db
  2. (optional step) Test the package by running cd node_modules/ice-db && npm test

Quick Start

  1. First import the module and instantiate the db .Thats it! Now you're ready to go :slightly_smiling_face:
const {
    Ice
} = require('ice-db');

const db = new Ice();
  1. To create a collection:
const animals = db.createCollection({
    name: 'animals'
})

Now you can call a collection by using variable animals or db.animals

  1. To add a new record:
let daisy = animals.insert({
    type: 'cat',
    name: 'Daisy'
})
/*
This will return an object like this:
{ id: '4e6387b1-ac38-4e42-b474-1c6eaee1302d',
  rev: '1-1542481509127',
  type: 'cat',
  name: 'Daisy' }, but the id and rev would be unique
*/
  1. Records can be accessed by id:
daisy = animals.get(daisy.id)
/*
{ id: '4e6387b1-ac38-4e42-b474-1c6eaee1302d',
  rev: '1-1542481509127',
  type: 'cat',
  name: 'Daisy' }
*/
  1. To list all records in a collection:
animals.list();
  1. To update the record, provide the updated object:
daisy.type = 'kitty'

let updatedDaisy = animals.update(daisy)
/*
{ id: '6b45e668-698d-4d86-ae4a-bceca15af055',
  rev: '2-1542482143081',
  type: 'kitty',
  name: 'Daisy' }
*/

Notice: make sure that the id and rev are there:

let invalid = {
    type: 'cat',
    name: 'Margaret'
}

try {
    animals.update(invalid)
} catch (e) {
    console.error(e.message)
    // ID is not defined
}
let invalid = {
    type: 'cat',
    name: 'Margaret',
    id: daisy.id
}

try {
    animals.update(invalid)
} catch (e) {
    console.error(e.message)
    // Rev is not defined
}
  1. Delete an object:
animals.delete(daisy)
  1. To clear all data in a collection:
animals.drop()

or

db.dropCollection(animals)

or

db.dropCollection('animals')
  1. You can set a persistent storage for a db:
db.setStorage({
    path: './storage'
})

// async
db.save().then(()=>{
    console.log('Saved')
})

// sync
db.save(true)

// this will create a json file with a name of a collection per each containing all data