myag.db
v1.3.0
Published
Cool database package
Downloads
16
Maintainers
Readme
Myag
Myag is a simple database implementation in JavaScript/TypeScript that allows you to store data using either JSON or SQLite.
Installation
You can install the package:
npm install myag.db
or
ban install myag.db
Usage
const { Myag } = require('myag.db');
// Create a new Myag instance with JSON storage
const myag = new Myag({
path: './data/database',
useJson: true
});
// Set a value
await myag.set('key', 'value');
// Get a value
const result = await myag.get('key');
console.log(result);
// Delete a value
await myag.delete('key');
API
Myag(options)
Creates a new Myag instance.
options
(object): Configuration options for the Myag instance.path
(string): The path where the database will be stored.useJson
(boolean): Set totrue
to use JSON storage, andfalse
to use SQLite.
Myag.set(key, value)
Sets a value in the database.
key
(string): The key to set.value
(any): The value to set.
Myag.get(key)
Gets a value from the database.
key
(string): The key to retrieve.
Myag.delete(key)
Deletes a value from the database.
key
(string): The key to delete.
Myag.push(key, value)
Pushes a value to an array in the database.
key
(string): The key of the array.value
(any): The value to push.