Add typing for execute methods

This commit is contained in:
Pierre Anctil
2015-12-24 08:44:46 +01:00
parent ddf001276e
commit 5b9d1a8c6a
2 changed files with 21 additions and 1 deletions
+18
View File
@@ -66,6 +66,15 @@ var connection: sql.Connection = new sql.Connection(config, function (err: any)
}
});
requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
if (err != null) {
console.error('Error happened calling Query: ' + err.name + " " + err.message);
}
else {
console.info(returnValue);
}
});
var requestStoredProcedureWithOutput = new sql.Request(connection);
var testId: number = 0;
var testString: string = 'test';
@@ -90,6 +99,15 @@ var connection: sql.Connection = new sql.Connection(config, function (err: any)
console.info(requestStoredProcedureWithOutput.parameters['output'].value);
}
});
requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
if (err != null) {
console.error('Error happened calling Query: ' + err.name + " " + err.message);
}
else {
console.info(requestStoredProcedureWithOutput.parameters['output'].value);
}
});
}
});
+3 -1
View File
@@ -200,7 +200,7 @@ declare module "mssql" {
public constructor(transaction: Transaction);
public constructor(preparedStatement: PreparedStatement);
public execute(procedure: string): Promise<recordSet>;
public execute(procedure: string, callback: (err?: any, recordsets?: any, returnValue?: any) => void): void;
public execute<Entity>(procedure: string, callback: (err?: any, recordsets?: Entity[], returnValue?: any) => void): void;
public input(name: string, value: any): void;
public input(name: string, type: any, value: any): void;
public output(name: string, type: any, value?: any): void;
@@ -258,7 +258,9 @@ declare module "mssql" {
public prepare(statement?: string): Promise<void>;
public prepare(statement?: string, callback?: (err?: any) => void): void;
public execute(values: Object): Promise<recordSet>;
public execute<Entity>(values: Object): Promise<Entity[]>;
public execute(values: Object, callback: (err: any, recordSet: recordSet) => void): void;
public execute<Entity>(values: Object, callback: (err: any, recordSet: Entity[]) => void): void;
public unprepare(): Promise<void>;
public unprepare(callback: (err?: any) => void): void;
}