npm package: @mrnima/local-database-manager
Description: A lightweight, file-based database manager for Node.js applications. This package provides simple and efficient methods for managing local JSON databases, including adding, retrieving, updating, and deleting records. Ideal for small projects and local dev
Author: MrNima
Latest version: 1.0.0

# @mrnima/local-database-manager
A lightweight, file-based database manager for Node.js applications. This package provides simple and efficient methods for managing local JSON databases, including adding, retrieving, updating, and deleting records. Ideal for small projects and local development environments.

## Features
- **Initialize Database**: Automatically create a new database file if it doesn't exist.
- **CRUD Operations**: Easily add, retrieve, update, and delete records.
- **File-based Storage**: Store your data in a local JSON file.
- **Simple API**: Intuitive and easy-to-use methods for database management.
- **Supports:** CommonJS and ES Modules.

## Installation

```sh
npm install @mrnima/local-database-manager
```
## Usage
#### CommonJS (CJS)
```JavaScript
// Import the Database class from the package
const Database = require('@mrnima/local-database-manager');

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

// Add data to the database with hobbies and cooking skills
db.addData({ 
    id: 1, 
    name: 'Mr Nima', 
    age: 20, 
    birth: '2004-07-27', 
    hobbies: ['reading', 'swimming'], 
    cookingSkills: ['kottume', 'pol sambola'],
    relationship: false
});
db.addData({ 
    id: 2, 
    name: "U.A.R.L. Piyasena", 
    age: 21, 
    birth: "2004-08-16", 
    hobbies: ["reading", "watching movies", "traveling"], 
    cookingSkills: ["Ala badum", "soya meet", "pol sambola"],
    relationship: true
});

// Get all data from the database
const data = db.getData();
console.log(data);

// Get an item by its ID
const item = db.find(1);
console.log(item);

// Update the name of the item with ID 1
const updateNameResult = db.update(1, { name: 'Updated Mr Nima' });
console.log(updateNameResult);

// Update the age of the item with ID 1
const updateAgeResult = db.update(1, { age: 21 });
console.log(updateAgeResult);

// Get all data again to see the updates
const updatedData = db.getData();
console.log(updatedData);

// Delete an item by its ID
const deleteResult = db.delete(1);
console.log(deleteResult); // true if the item was deleted, false otherwise
```
#### ES Modules (ESM)
```JavaScript
// Import the Database class from the package
import Database from '@mrnima/local-database-manager';

const db = new Database('db.json');

// Add data to the database with hobbies and cooking skills
db.addData({ 
    id: 1, 
    name: 'Mr Nima', 
    age: 20, 
    birth: '2004-07-27', 
    hobbies: ['reading', 'swimming'], 
    cookingSkills: ['kottume', 'pol sambola'],
    relationship: false
});
db.addData({ 
    id: 2, 
    name: "U.A.R.L. Piyasena", 
    age: 21, 
    birth: "2004-08-16", 
    hobbies: ["reading", "watching movies", "traveling"], 
    cookingSkills: ["Ala badum", "soya meet", "pol sambola"],
    relationship: true
});

// Get all data from the database
const data = db.getData();
console.log(data);

// Get an item by its ID
const item = db.find(1);
console.log(item);

// Update the name of the item with ID 1
const updateNameResult = db.update(1, { name: 'Updated Mr Nima' });
console.log(updateNameResult);

// Update the age of the item with ID 1
const updateAgeResult = db.update(1, { age: 21 });
console.log(updateAgeResult);

// Get all data again to see the updates
const updatedData = db.getData();
console.log(updatedData);

// Delete an item by its ID
const deleteResult = db.delete(1);
console.log(deleteResult); // true if the item was deleted, false otherwise
```
## License
MIT