axiodb
Version:
A blazing-fast, lightweight, and scalable nodejs package based DBMS for modern application. Supports schemas, encryption, and advanced query capabilities.
60 lines (59 loc) • 2.7 kB
TypeScript
import Database from "./Database/database.operation";
import { ErrorInterface, SuccessInterface } from "../config/Interfaces/Helper/response.helper.interface";
/**
* Class representing the AxioDB database.
* @param {string} RootName - The name of the root folder.
* @returns {AxioDB} - Returns the instance of AxioDB.
*/
export declare class AxioDB {
private readonly RootName;
private currentPATH;
private fileManager;
private folderManager;
private Converter;
private ResponseHelper;
private static _instance;
constructor(RootName?: string, CustomPath?: string);
/**
* Initializes the root directory for the AxioDB.
*
* This method sets the `currentPATH` to include the `RootName` and checks if the AxioDB folder exists.
* If the folder does not exist, it attempts to create it. If the creation fails, an error is thrown.
*
* @throws {Error} If the AxioDB folder cannot be created.
* @returns {Promise<void>} A promise that resolves when the initialization is complete.
*/
private initializeRoot;
/**
* Creates a new database folder and updates the metadata file.
* @param DBName - The name of the database to create.
* @returns The newly created database object.
*/
createDB(DBName: string): Promise<Database>;
/**
* Retrieves information about the databases in the current directory.
*
* This method performs the following operations:
* 1. Lists all directories (databases) in the current path.
* 2. Calculates the total size of the current directory.
* 3. Checks if the data from both operations is returned.
* 4. Logs the number of databases.
* 5. Constructs an object containing the total size, total number of databases, and the list of databases.
* 6. Sends a success response with the constructed object.
*
* @returns {Promise<SuccessInterface | undefined>} A promise that resolves when the database information is successfully retrieved and the response is sent.
*/
getDatabaseInfo(): Promise<SuccessInterface | undefined>;
/**
* Deletes a database from the current directory.
*
* This method performs the following operations:
* 1. Checks if the database exists.
* 2. Deletes the database if it exists.
* 3. Sends a success response if the database is deleted.
*
* @param {string} DBName - The name of the database to delete.
* @returns {Promise<SuccessInterface>} A promise that resolves when the database is successfully deleted and the response is sent.
*/
deleteDatabase(DBName: string): Promise<SuccessInterface | ErrorInterface | undefined>;
}