0.2.11 • Published 4 years ago
slayercio-json-database v0.2.11
Slayercio JSON Database
It's a small json database library to use in your Javascript / Typescript projects. It saves files as base64 encoded JSON string and automatically loads at initialization. Only dependency it has is slayercio-logger that's used to log errors.
Usage
Import Database class from library
// JavaScript const { Database } = require("slayercio-json-database"); // TypeScript import { Database } from "slayercio-json-database";
Create new Database
const database = new Database( Name /* Name of the database */, Path /* Path to the database file*/ );
Elements operations
- 3.1 Add to database
// Returns index of added element let indexOfElement = database.AddElement(Object);
- 3.2 Remove from database
// Returns if element was successfully removed let status = database.RemoveElement(Index);
- 3.1 Add to database
- Save / Load database
- 4.1 To load database use:
// Returns if load was successful database.Load();
- 4.2 To save database use:
// Returns if save was successful database.Save();