axiodb
Version:
A blazing-fast, lightweight, and scalable nodejs package based DBMS for modern application. Supports schemas, encryption, and advanced query capabilities.
53 lines (52 loc) • 2.24 kB
TypeScript
import { AxioDB } from "../../../Services/Indexation.operation";
import { ResponseBuilder } from "../../helper/responseBuilder.helper";
import { FastifyRequest } from "fastify";
/**
* Controller class for managing databases in AxioDB.
*
* This class provides methods for retrieving database information,
* creating new databases, and other database management operations.
* It acts as an interface between the API routes and the AxioDB instance.
*/
export default class DatabaseController {
private AxioDBInstance;
constructor(AxioDBInstance: AxioDB);
/**
* Retrieves a list of databases from the AxioDB instance.
*
* @returns {Promise<ResponseBuilder>} A Promise that resolves to a ResponseBuilder object
* containing the list of databases with an OK status code and a success message.
*
* @example
* const response = await databaseController.getDatabases();
* // Returns a ResponseBuilder with status 200 and database list
*/
getDatabases(): Promise<ResponseBuilder>;
/**
* Creates a new database with the specified name.
*
* @param request - The Fastify request object containing the database name in the body
* @returns A ResponseBuilder object containing the status and message of the operation
*
* @throws Will return a conflict response if database already exists
* @throws Will return a bad request response if name is missing, not a string, or empty
* @throws Will return an internal server error response if database creation fails
*/
createDatabase(request: FastifyRequest): Promise<ResponseBuilder>;
/**
* Deletes a database with the specified name.
*
* @param request - The Fastify request object containing the database name in the body
* @returns A ResponseBuilder object with appropriate status code and message
* - 200 OK if the database is successfully deleted
* - 404 NOT_FOUND if the database does not exist
* - 500 INTERNAL_SERVER_ERROR if an error occurs during deletion
*
* @example
* // Example request body
* {
* "name": "myDatabase"
* }
*/
deleteDatabase(request: FastifyRequest): Promise<ResponseBuilder>;
}