@oino-ts/db-mssql
Version:
OINO TS package for using Microsoft Sql databases.
101 lines (100 loc) • 3.08 kB
TypeScript
import { OINODb, OINODbParams, OINODbDataSet, OINODbApi, OINODataCell, OINOResult } from "@oino-ts/db";
/**
* Implementation of MariaDb/MySql-database.
*
*/
export declare class OINODbMsSql extends OINODb {
private _pool;
/**
* Constructor of `OINODbMsSql`
* @param params database parameters
*/
constructor(params: OINODbParams);
private _query;
private _exec;
/**
* Print a table name using database specific SQL escaping.
*
* @param sqlTable name of the table
*
*/
printSqlTablename(sqlTable: string): string;
/**
* Print a column name with correct SQL escaping.
*
* @param sqlColumn name of the column
*
*/
printSqlColumnname(sqlColumn: string): string;
/**
* Print a single data value from serialization using the context of the native data
* type with the correct SQL escaping.
*
* @param cellValue data from sql results
* @param sqlType native type name for table column
*
*/
printCellAsSqlValue(cellValue: OINODataCell, sqlType: string): string;
/**
* Print a single string value as valid sql literal
*
* @param sqlString string value
*
*/
printSqlString(sqlString: string): string;
/**
* Parse a single SQL result value for serialization using the context of the native data
* type.
*
* @param sqlValue data from serialization
* @param sqlType native type name for table column
*
*/
parseSqlValueAsCell(sqlValue: OINODataCell, sqlType: string): OINODataCell;
/**
* Print SQL select statement with DB specific formatting.
*
* @param tableName - The name of the table to select from.
* @param columnNames - The columns to be selected.
* @param whereCondition - The WHERE clause to filter the results.
* @param orderCondition - The ORDER BY clause to sort the results.
* @param limitCondition - The LIMIT clause to limit the number of results.
* @param groupByCondition - The GROUP BY clause to group the results.
*
*/
printSqlSelect(tableName: string, columnNames: string, whereCondition: string, orderCondition: string, limitCondition: string, groupByCondition: string): string;
/**
* Connect to database.
*
*/
connect(): Promise<OINOResult>;
/**
* Validate connection to database is working.
*
*/
validate(): Promise<OINOResult>;
/**
* Execute a select operation.
*
* @param sql SQL statement.
*
*/
sqlSelect(sql: string): Promise<OINODbDataSet>;
/**
* Execute other sql operations.
*
* @param sql SQL statement.
*
*/
sqlExec(sql: string): Promise<OINODbDataSet>;
private _getSchemaSql;
private _getValidateSql;
/**
* Initialize a data model by getting the SQL schema and populating OINODbDataFields of
* the model.
*
* @param api api which data model to initialize.
*
*/
initializeApiDatamodel(api: OINODbApi): Promise<void>;
}