Setup
The use is so simple that you just have to start the class and use a function to start using the database.
const const database: Database<"main">
database = new new Database<"main">({ root, tables, auth }: DatabaseOptions<"main">): Database<"main">
Constructs the Database class
Database({ DatabaseOptions<T extends string>.root: string
Relative root directory of the database
root: './database/', // Folder to create the json files that are the tables. DatabaseOptions<"main">.tables: "main"[]
Tables of the database
tables: ['main'], // Tables to be used
DatabaseOptions<T extends string>.auth?: string
Authentication key for each operation
auth: const AUTH_KEY: string
AUTH_KEY // Authentication code, I recommend that it be placed in a `.env` file.});
const database: Database<"main">
database.Database<"main">.begin(): Promise<void>
Begins the Database by verifying tables and creating them if they do not exist.
begin() // Creates all necessary files and folders
Following the above example, your files should look something like this:
- package.json
Directorysrc
Directorydatabase
- main.json
- …