kmk-mssqlclient
Installation
npm install kmk-mssqlclient
Usage
Initialization
const SqlClient = ;const cn = ;cn;
Connecting
cn /* OR */ SqlClient
Connecting using async/await mode
async { try await cn; console; catche console; }
Querying data
cn
Querying data using async/await mode
async { try let result = await cn; console; catche console; }
Methods
Method Name | Returns | Parameters | Description |
---|---|---|---|
connect | Promise<void<T>> | (void) | Connects to a MS SQL Server |
query<T> | Promise<IQueryResult<T>> | (sqlCommandStatement: string, ...optionalParams: any[]) | Executes a sql query and returns recordsets and rows affected |
executeRowSet<T> | Promise<Array<T>> | (sqlCommandStatement: string, ...optionalParams: any[]) | Executes a query and returns the first rowSet for that query |
executeLastRowSet<T> | Promise<Array<T>> | (sqlCommandStatement: string, ...optionalParams: any[]) | Executes a query and returns the last rowSet for that query |
executeRowSets | Promise<Array>> | (sqlCommandStatement: string, ...optionalParams: any[]) | Executes a query and returns all rowSets for that query |
fetchRow<T> | Promise<T> | (sqlCommandStatement: string) | Executes a query and returns the first row from the first rowSet for that query |
fetchColumn | (sqlCommandStatement: string, index: number | string = 0) | Executes a query and returns a specific field (index or name) from the first row from the first rowSet for that query | |
executeNonQuery | Promise<number> | (sqlCommandStatement: string, ...optionalParams: any[]) | Executes a sql statement and returns affected row count |
getLastsqlCommandStatement | string | (void) | Returns the last sqlCommandStatement executed |