Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khalby786/jsoning
✨ A simple key-value JSON-based lightweight database. ✨
https://github.com/khalby786/jsoning
async database datastore hacktoberfest javascript json key-value nodejs npm
Last synced: 1 day ago
JSON representation
✨ A simple key-value JSON-based lightweight database. ✨
- Host: GitHub
- URL: https://github.com/khalby786/jsoning
- Owner: khalby786
- License: mit
- Created: 2020-05-04T14:57:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-27T08:06:45.000Z (9 months ago)
- Last Synced: 2024-12-01T02:13:02.791Z (22 days ago)
- Topics: async, database, datastore, hacktoberfest, javascript, json, key-value, nodejs, npm
- Language: TypeScript
- Homepage: http://jsoning.js.org/
- Size: 4.99 MB
- Stars: 92
- Watchers: 6
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
✨ A simple key-value JSON-based lightweight database. ✨
![CodeCov](https://codecov.io/gh/khalby786/jsoning/branch/master/graph/badge.svg)
[![Build Status](https://travis-ci.org/khalby786/jsoning.svg?branch=master)](https://travis-ci.org/khalby786/jsoning)
[![Latest Stable Version](https://img.shields.io/npm/v/jsoning.svg)](https://www.npmjs.com/package/jsoning)
[![NPM Downloads](https://img.shields.io/npm/dm/jsoning.svg)](https://www.npmjs.com/package/jsoning)
![node-current](https://img.shields.io/node/v/jsoning)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkhalby786%2Fjsoning.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkhalby786%2Fjsoning?ref=badge_shield)
[View Demo](https://glitch.com/edit/#!/jsoning) · [Report Bug](https://github.com/khalby786/jsoning/issues) · [Request Feature](https://github.com/khalby786/jsoning/issues)
---
Jsoning is a simplified wrapper for Node.js that lets you write and read data to and from JSON files. It's designed to be beginner-friendly and easy to use, with a simple API that makes it easy to get started with. It's perfect for small projects, prototyping, and learning how to work with databases.
## Features
- Use existing JSON files to read and write key-value pairs
- EventEmitters to listen to changes in the database
- Atomic file writing to prevent data corruption
- Easier to use than a toaster
- TypeScript support for all the fixed-type addicts out there## Install
**Node.js v16.x or greater is required for this package to work.**
```bash
npm i jsoning# pnpm if you're feeling fast
pnpm i jsoning# yarn if you're feeling fancy
yarn add jsoning
```View the full documentation [here](https://jsoning.js.org/).
## Basic Usage
```ts
import { Jsoning, MathOps } from 'jsoning';
const db = new Jsoning('database.json');// 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');// Get the value of a key
console.log(await db.get('transformers')); // [ 'optimus prime', 'bumblebee', 'iron hide' ]// Get all the values
console.log(await db.all()); // { Record 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
await db.math('money', MathOps.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](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Khaleel Gibran
💻 📖 🎨 🚇 ⚠️ ✅
David
📖
Jonyk56
💻
ayntee
💻
undefine
💻 🐛 🛡️
Aditya Gupta
💻
Manuel Maly
💻 🐛
wh0
💻
akpi816218
💻 📖 💡 🚧 ⚠️ 🔧
This project follows the [all-contributors](https://allcontributors.org) specification.
Contributions of any kind are welcome!## License
This package is open sourced under the [MIT License](https://github.com/khalby786/jsoning/blob/master/LICENSE.md).
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkhalby786%2Fjsoning.svg?type=small)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkhalby786%2Fjsoning?ref=badge_large)