slayercio-json-database

0.2.11 • Public • Published

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

  1. Import Database class from library

    // JavaScript
    const { Database } = require("slayercio-json-database");
    // TypeScript
    import { Database } from "slayercio-json-database";
  2. Create new Database

    const database = new Database(
      Name /* Name of the database */,
      Path /* Path to the database file*/
    );
  3. 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);
  4. 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();

Readme

Keywords

Package Sidebar

Install

npm i slayercio-json-database

Weekly Downloads

1

Version

0.2.11

License

MIT

Unpacked Size

13.3 kB

Total Files

9

Last publish

Collaborators

  • slayercio