DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 967,911 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Jsoning - A simple key-value JSON-based persistent lightweight database.โœจ
Khaleel Gibran
Khaleel Gibran

Posted on • Updated on

Jsoning - A simple key-value JSON-based persistent lightweight database.โœจ

jsoning

โœจ A simple key-value JSON-based persistent lightweight database. โœจ


View Demo ยท Report Bug ยท Request Feature ยท Star On GitHub

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


Like us a lot? Help others know why you like us! Review this package on pkgreview.dev โžก Review us on pkgreview.dev

Features

  • ๐Ÿ“ Uses JSON files to modify and write key-value elements as JSON-objects.
  • ๐Ÿ‘Œ Easy to use JSON database.
  • ๐Ÿšซ Prevents JSON corruption with atomic file writing.
  • 1๏ธโƒฃ Uses only 1 dependency (write-file-atomic)
  • ๐Ÿ•Š๏ธ Lightweight package with an unpacked size of 12.1 kB.
  • ๐Ÿ–ฅ๏ธ Requires Node.js v12.x or greater

Install ๐Ÿ’พ

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

npm install jsoning
Enter fullscreen mode Exit fullscreen mode

View the full documentation here.

Basic Usage ๐Ÿ“‘

let jsoning = require('jsoning');
let database = new jsoning("database.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

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

})();

Enter fullscreen mode Exit fullscreen mode

Links ๐Ÿ”—

Contributing

Please see CONTRIBUTING.md for more details on contributing!

License

This package is open sourced under the MIT License.

FOSSA Status

Top comments (2)

Collapse
 
javaarchive profile image
Raymond

Nice way to evolve my amazingly simple json reading code for better readability.

Collapse
 
khalby786 profile image
Khaleel Gibran Author

Thanks for the valuable feedback! This is actually my first project that has been this successful!

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. ๐Ÿ›