import { DatabaseValues, ValidConnectionType } from './types.d'; import ManagedDatabaseConnection from './utils/managedDatabaseConnection'; declare abstract class FundementalDatabaseModel { /** -- To Be Defined In Implementatino ----------------------------------------------------------- */ protected static tableName: string; protected static primaryKey: string; protected static primaryKeyType: string; protected static createDatabaseConnection: () => Promise; protected static managedDatabaseConnection: ManagedDatabaseConnection; /** -- Data Extraction ----------------------------------------------------------- */ protected abstract readonly databaseValues: DatabaseValues; /** -- Static Queries ----------------------------------------------------------- */ /** findAll (e.g., read) */ static findAll({ querybase, values }: { querybase: string; values: any; }): Promise; /** findById (e.g., read) */ protected static FIND_BY_PRIMARY_KEY_QUERY: string; static findByPrimaryKey(value: string | number): Promise; /** findByUniqueAttributes (e.g., read) */ protected static FIND_BY_UNIQUE_ATTRIBUTES_QUERY: string; static findByUniqueAttributes(values: any): Promise; /** -- Fundemental CRUD ---------------------------------------------------------- */ /** Create: - abstracts the recurring elements of create and createIfDoesNotExist - considers and handles three types of primary keys: - auto increment - uuid - custom Logic: 0. validate the request - ensure query is defined 1. validate the primary key - ensure its null at first - if its a uuid, generate the uuid value 2. run the query 3. return the key - if its a uuid, return the value defined - return the lastInsertedId otherwise */ protected static CREATE_QUERY: string; create(): Promise; /** upsert object - upserts should only be defined based on uniquely identifiable attributes of the data - due to the nature of upserting, we will either create or find it already created each time and thus must get the id in a seperate step each time. @returns {undefined} - nothing is returned since the id must be queried for in a seperate step */ protected static UPSERT_QUERY: string; upsert(): Promise; /** update object */ protected static UPDATE_QUERY: string; update(): Promise; /** delete (by id) */ protected static DELETE_QUERY: string; delete(): Promise; /** -- Query Execution ---------------------------------------------------------- */ /** execute - supports the `:table_name` and `:primary_key` variable column names; replaces them with their real value before running the query - supports specifying 'explicit' parameters with `x:` notation, contrasted to `:` notation; replaces each of these values with its string literal before running the query - supports reusing a managedDatabaseConnection OR creating a new database connection each time - executes the resulting query with the exact values that were passed in */ static execute({ querybase, values }: { querybase: string; values?: any; }): Promise; } export default FundementalDatabaseModel;