Giter VIP home page Giter VIP logo

jsoning's Introduction

jsoning

✨ A simple key-value JSON-based persistent lightweight database. ✨


CodeCov Build Status Latest Stable Version NPM Downloads node-current FOSSA Status


View Demo · Report Bug · Request Feature

Loved the project? Please consider donating to help it improve!


🚨 Since v0.10.19, JSON files are generated in the current working directory, rather than within the node_modules which resulted in loss of the JSON files whenever packages were re-installed!

Features ✨

  • Uses JSON files to modify and write key-value elements.
    • This allows for the usage of pre-existing JSON files by specifying the path when creating a new instance of Jsoning.
  • Easy to use, beginner-friendly and lightweight.
  • Writes atomically to prevent file corruption.

Install 💾

Node.js v12.x or greater is required for this package to work.

# npm
npm install jsoning

# or yarn if you're feeling fancy
yarn add jsoning

View the full documentation here.

Basic Usage 📑

let jsoning = require("jsoning");
let db = new jsoning("db.json");

(async () => {
	// set some values with a key
	await db.set("birthday", "07-aug");
	await db.set("age", "13");

	// push stuff to an array for a particular key
	await db.push("transformers", "optimus prime");
	await db.push("transformers", "bumblebee");
	await db.push("transformers", "iron hide");

	// simply log what get is (i forgot what the transformers were)
	console.log(await db.get("transformers")); // [ 'optimus prime', 'bumblebee', 'iron hide' ]

	// just want to see what all is there
	console.log(await db.all()); // { object of the whole database contents }

	// does such a value exist
	console.log(await db.has("value2")); // false

	// my age keeps changing, so I'm deleting it
	console.log(await db.delete("age")); // true

	// i got 100$ for my birthday
	await db.set("money", 100);

	// and someone gave me 200 more dollars xD
	await db.math("money", "add", 200);

	// just wanna make sure how much money I got
	console.log(await db.get("money")); // 300

	// rip iron hide, he died
	await db.remove("transformers", "iron hide");

	// i'm getting bored, so i'm clearing the whole database
	await db.clear();
})();

Contributing

Please see CONTRIBUTING.md for more details on contributing!

Contributors

All Contributors

Thanks goes to these wonderful people (emoji key):


Khaleel Gibran

💻 📖 🎨 🚇 ⚠️

David

📖

Jonyk56

💻

ayntee

💻

undefine

💻 🐛 🛡️

Aditya Gupta

💻

Manuel Maly

💻 🐛

wh0

💻

This project follows the all-contributors specification. Contributions of any kind are welcome!

License

This package is open sourced under the MIT License.

FOSSA Status

jsoning's People

Contributors

khalby786 avatar allcontributors[bot] avatar manmal avatar dependabot[bot] avatar adi-g15 avatar ygorperez avatar fossabot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.