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

cheffydb

v1.0.7

Published

Fast, tiny, simple JSON database

Downloads

23

Readme

CheffyDB

CheffyDB is a fast, tiny, simple JSON database package with backup system.

🧭 How To Use

npm install cheffydb

A database file named cheffydb.json will be created automatically (when used).

⛳ Examples

const db = require("cheffydb");

db.set("test", "123"); //Output: 123
db.push("test123", "a"); //Output: ["a"]
db.push("test123",  "b"); //Output: ["a","b"]
db.add("number", 3); //Output: 3
db.add("number", 50); //Output: 53
db.subtract("number", 10); //Output: 43
db.all(); //Output: [{ ID:'test',data:'123'},{ID:'test123',data:['a','b']},{ID:'number',data:43}]
db.delete("number"); //Output: true
db.deleteAll(); //Output: true

db.get("test"); //Output: ["a","b"]
db.get("test123"); //Output: 123
db.fetch("test"); //Output: 123
db.check("test"); //Output: true
db.has("test"); //Output: true

Import from Another Database Package/JSON File

//from package
const db = require("cheffydb");
const otherdb = require("exampledb");
db.importFromDB(otherdb); //Output: true

//from JSON file
const db = require("cheffydb");
db.importFromJSONFile("./database.json"); //Output: true

Backing Up the Database File

const db = require("cheffydb");
db.createBackup("./backup.json"); //Automatically creates the backup file

db.loadBackup("./backup.json");
db.loadBackup("./backup.json", true); //true means the database file will be cleaned before the backup is loaded

Database Encryption

To use this, put this code at the top of your main file:

require("cheffydb").encryption(true, "encryption key"); //⚠️⚠️⚠️ Do not type your key at here if you have public project.

Store your encryption key where no one can access it (you can use .env if you have in your project). Replace the "encryption key" string with process.env.encKey to use environment variables.

const db = require("cheffydb");
//db.encryption(mode,key);
db.encryption(true,process.env.encKey);
db.set("test", "123");
db.encryption(false,process.env.encKey);

⚠️ WARNING: Store your encryption key where no one can access it (like .env in your projects). If you lose your encryption key, you may lose access to the database. We are not responsible if your data is stolen/lost. This feature is experimental. It is not recommended to use this.