Skip to content

RengaN02/saverdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Saver Database Module

A lightweight JSON-based database for Node.js projects.

Downloads
Version


Installation

npm i saver.db

Usage Examples

JavaScript

const Database = require("saver.db");

// Initialize the database
const db = new Database('./database.json');

// Set a value
db.set('UserId', '368695088718544896');

// Add a number to an existing value
db.add('UserNumber', 5);

// Subtract a number from an existing value
db.extract('UserNumber', 2);

// Delete a specific key
db.delete('UserAvatar');

// Push a value to an array
db.push('UserList', 'John Doe');

// Check if a key exists
console.log(db.has('UserList')); // true or false

// Fetch a specific value
console.log(db.fetch('UserList'));

// Fetch all data
console.log(db.fetchAll());

// Clear the database
db.clear();

TypeScript

import Database from "saver.db";

// Initialize the database
const db = new Database('./database.json');

// Set a value
db.set('UserId', '368695088718544896');

// Add a number to an existing value
db.add('UserNumber', 5);

// Subtract a number from an existing value
db.extract('UserNumber', 2);

// Delete a specific key
db.delete('UserAvatar');

// Push a value to an array
db.push('UserList', 'John Doe');

// Check if a key exists
console.log(db.has('UserList')); // true or false

// Fetch a specific value
console.log(db.fetch('UserList'));

// Fetch all data
console.log(db.fetchAll());

// Clear the database
db.clear();

Features

  1. Lightweight: Uses a JSON file to store and manage data.
  2. Simple API: Provides methods to create, read, update, and delete data.
  3. TypeScript Support: Fully supports type definitions for better development experience.

Notes

  • By default, the database file is created at ./database.json. To use a custom file path:
    const db = new Database('./custom/path/database.json');

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published