mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[mssql] add beforeConnect type to config (#38487)
Raised in issue #38367
This commit is contained in:
parent
66b1826174
commit
31b1f54432
12
types/mssql/index.d.ts
vendored
12
types/mssql/index.d.ts
vendored
@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
import events = require('events');
|
||||
import tds = require('tedious');
|
||||
export interface ISqlType {
|
||||
type: ISqlTypeFactory;
|
||||
}
|
||||
@ -138,7 +139,7 @@ export interface IResult<T> {
|
||||
}
|
||||
|
||||
export interface IBulkResult {
|
||||
rowsAffected: number;
|
||||
rowsAffected: number;
|
||||
}
|
||||
|
||||
export interface IProcedureResult<T> extends IResult<T> {
|
||||
@ -201,6 +202,11 @@ export interface config {
|
||||
parseJSON?: boolean;
|
||||
options?: IOptions;
|
||||
pool?: IPool;
|
||||
/**
|
||||
* Invoked before opening the connection. The parameter conn is the configured
|
||||
* tedious Connection. It can be used for attaching event handlers.
|
||||
*/
|
||||
beforeConnect?: (conn: tds.Connection) => void
|
||||
}
|
||||
|
||||
export declare class ConnectionPool extends events.EventEmitter {
|
||||
@ -216,7 +222,7 @@ export declare class ConnectionPool extends events.EventEmitter {
|
||||
public query<Entity>(command: string, callback: (err?: Error, recordset?: IResult<Entity>) => void): void;
|
||||
public batch(batch: string): Promise<IResult<any>>;
|
||||
public batch(strings: TemplateStringsArray, ...interpolations: any[]): Promise<IResult<any>>;
|
||||
public batch(batch: string, callback: (err?: Error, recordset?: IResult<any>) => void): void;
|
||||
public batch(batch: string, callback: (err?: Error, recordset?: IResult<any>) => void): void;
|
||||
public batch<Entity>(batch: string): Promise<IResult<Entity>>;
|
||||
public batch<Entity>(strings: TemplateStringsArray, ...interpolations: any[]): Promise<IResult<Entity>>;
|
||||
public connect(): Promise<ConnectionPool>;
|
||||
@ -319,7 +325,7 @@ export declare class Request extends events.EventEmitter {
|
||||
public query<Entity>(command: string, callback: (err?: Error, recordset?: IResult<Entity>) => void): void;
|
||||
public batch(batch: string): Promise<IResult<any>>;
|
||||
public batch(strings: TemplateStringsArray, ...interpolations: any[]): Promise<IResult<any>>;
|
||||
public batch(batch: string, callback: (err?: Error, recordset?: IResult<any>) => void): void;
|
||||
public batch(batch: string, callback: (err?: Error, recordset?: IResult<any>) => void): void;
|
||||
public batch<Entity>(batch: string): Promise<IResult<Entity>>;
|
||||
public batch<Entity>(strings: TemplateStringsArray, ...interpolations: any[]): Promise<IResult<Entity>>;
|
||||
public batch<Entity>(batch: string, callback: (err?: any, recordset?: IResult<Entity>) => void): void;
|
||||
|
||||
@ -16,6 +16,11 @@ var config: sql.config = {
|
||||
},
|
||||
pool: {
|
||||
autostart: true
|
||||
},
|
||||
beforeConnect: conn => {
|
||||
conn.on('debug', message => console.info(message));
|
||||
conn.on('error', err => console.error(err));
|
||||
conn.removeAllListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +167,7 @@ function test_promise_returns() {
|
||||
connection.query<Entity>('SELECT 1 as value').then(res => { });
|
||||
connection.query`SELECT ${1}`.then((recordset) => { });
|
||||
connection.batch('create procedure #temporary as select * from table').then((recordset) => { });
|
||||
connection.batch<Entity>('create procedure #temporary as select * from table;select 1 as value').then((recordset) => { });
|
||||
connection.batch<Entity>('create procedure #temporary as select * from table;select 1 as value').then((recordset) => { });
|
||||
connection.batch`create procedure #temporary as select ${1} from table`.then((recordset) => { });
|
||||
connection.batch<Entity>`create procedure #temporary as select ${1} from table`.then((recordset) => { });
|
||||
|
||||
|
||||
@ -21,4 +21,4 @@
|
||||
"msnodesqlv8.d.ts",
|
||||
"mssql-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user