@defikitdotnet/education-module-ai
Version:
AI Education Module using Agent Framework
48 lines (47 loc) • 1.48 kB
TypeScript
import Database from "better-sqlite3";
/**
* DatabaseAdapter interface to standardize database operations
* This provides a consistent API for database access across the application
*/
export interface DatabaseAdapter {
db: Database.Database;
/**
* Execute a SELECT query and return all matching rows
* @param sql SQL query with placeholders
* @param params Query parameters
* @returns Array of matching rows
*/
all(sql: string, params?: any[]): Promise<any[]>;
/**
* Execute a SELECT query and return the first matching row
* @param sql SQL query with placeholders
* @param params Query parameters
* @returns First matching row or undefined if none found
*/
get(sql: string, params?: any[]): Promise<any>;
/**
* Execute an INSERT, UPDATE, or DELETE query
* @param sql SQL query with placeholders
* @param params Query parameters
* @returns Result object with lastID and changes properties
*/
run(sql: string, params?: any[]): Promise<{
lastID: number;
changes: number;
}>;
/**
* Prepare a statement for later execution
* @param sql SQL query with placeholders
* @returns Prepared statement
*/
prepare(sql: string): any;
/**
* Execute a SQL query without returning results
* @param sql SQL query
*/
exec(sql: string): void;
/**
* Close the database connection
*/
close(): void;
}