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

zip-db

v1.3.0

Published

Lightweight, Encrypted & Compressed Database implementation for NodeJS ๐Ÿ’พ

Downloads

3

Readme

zip-db

Lightweight JSON based Database implementation for NodeJS, which is designed for a small volume of stored data. No additional Database drivers are required.

The Database will be:

  • persisted into the local file system
  • encrypted with aes-256-ctr
  • compressed

Example

const ZipDb = require("zip-db");

// Initialize a database that will be persisted in the file "mydb.db".
// The database will be encrypted by using the password "my-password".
const db = new ZipDb(__dirname + "/mydb.db", "my-password");

// add a new collection
const peopleCollection = db.createCollection("people");

// add a new document to the collection
const johnCenasId = peopleCollection.add({
  firstName: "John",
  lastName: "Cena",
  symbol: "๐Ÿ’ช๐Ÿป",
});

// get an array of all entities in the collection
const allPeople = peopleCollection.getAll();

// get a specific document from the collection
const johnCena = peopleCollection.getById(johnCenasId);

// update john cena
const updatedJohnCena = peopleCollection.update(johnCenasId, {
  firstName: "John",
  lastName: "Cena",
  symbol: "๐ŸฅŠ",
});

// delete a document from the collection
peopleCollection.removeById(johnCenasId);

// remove all entites from collection
peopleCollection.truncate();

// remove people collection
db.removeCollection("people");

// add a collection of fruits, if it does not exist yet
const fruitCol = db.hasCollection("fruits")
  ? db.getCollection("fruits")
  : db.createCollection("fruits");

// add tasty fruits
fruitCol.add({ name: "Apple", symbol: "๐ŸŽ" });
fruitCol.add({ name: "Banana", symbol: "๐ŸŒ" });
fruitCol.add({ name: "Melon", symbol: "๐Ÿ‰" });

// print all documents of all collections
db.getAllCollections().forEach(col => {
  console.log(col.name, col.getAll());
});

// persist changes to database
db.persist();

// add a collection of junkfood
const junkCol = db.createCollection("junkfood");
junkCol.add({ name: "Burger", symbol: "๐Ÿ”" });
junkCol.add({ name: "Fries", symbol: "๐ŸŸ" });
junkCol.add({ name: "Pizza", symbol: "๐Ÿ•" });

// we roll back the database to the last .persist() call
// this erases the bad junkfood collection again
db.rollBack();