UNPKG

@szegedsw/lib-node

Version:

A little framework published by Szeged Software Zrt. in order to enhance api endpoint security and create reuseable code. Email module, Logging system, and much more. Further improvements are expected.

26 lines 1.48 kB
import Knex, { CreateTableBuilder } from "knex"; declare type creatorFunction = (tb: CreateTableBuilder) => void; export declare class Database { static Connector: Knex; static init(config: Knex.Config): Knex; /** * @method table_create used to create a table in database. * Table will be created only if it does not exist. If you want to create the table anyway, use the `forceDrop` flag. * @param tablename table name in database * @param creator this is the table creator function * @param forceDrop Force table drop if it exists then create it. If it is set to false, table won't be created if already exists. */ static table_create(tablename: string, creator: creatorFunction, forceDrop?: boolean): Promise<void>; /** * @method insert data into database table * @param tablename tablename for insertion * @param binds obje {column_name: value} * @param checkUniqueness whether to check if row exists. * "Duplicate key" error can be suppressed with it, because we try to insert only if it does not exists. * @returns Promise is rejected on error. Promise resolves to true only if insertion was successful. * Resolves to false only if param(checkUniqueness) was requested and insertion would be resulted in error. */ static insert(tablename: string, binds: Record<string, unknown>, checkUniqueness?: boolean): Promise<boolean>; } export {}; //# sourceMappingURL=database.d.ts.map