@crexy/simple-database

1.0.1 • Public • Published

@crexy/simple-database

A simple JSON-based database module

Installation

npm i @crexy/simple-database

Usage

Create a Database Instance

const  SimpleDatabase = require('@crexy/simple-database');

// Create a new instance of the database with the specified JSON file  
const db = new  SimpleDatabase('data.json');

Set Key-Value Pairs

db.set('name', 'Crexy');
db.set('age', 18);

Get Values by Key

console.log('Name:', db.get('name')); // Output: Name: Crexy  
console.log('Age:', db.get('age')); // Output: Age: 18

Get All Key-Value Pairs

console.log('All Data:', db.getAll());

Remove a Key-Value Pair

db.remove('age'); console.log('Updated Data:', db.getAll());

Example

const SimpleDatabase = require('@crexy/simple-database');

const db = new SimpleDatabase('data.json');

db.set('name', 'Crexy');
db.set('age', 18);

console.log('Name:', db.get('name'));
console.log('Age:', db.get('age'));
console.log('All Data:', db.getAll());

db.remove('age');
console.log('Updated Data:', db.getAll());

License

This project is licensed under the MIT License - see the LICENSE file for details.

Questions

If you've any question, you can join to our Discord server: Click me!

Readme

Keywords

Package Sidebar

Install

npm i @crexy/simple-database

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

3.5 kB

Total Files

4

Last publish

Collaborators

  • crexy