diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 2167aaf40..17c7761d6 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -278,6 +278,7 @@ All definitions files include a header with the author and editors, so at some p * [morgan](https://github.com/expressjs/morgan/) (by [James Roland Cabresos](https://github.com/staticfunction/)) * [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz)) * [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) +* [msnodesql](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov) and [Maxime LUCE](https://github.com/SomaticIT)) * [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) * [mysql](https://github.com/felixge/node-mysql) (by [William Johnston](https://github.com/wjohnsto)) * [nconf](https://github.com/flatiron/nconf) (by [Jeff Goddard](https://github.com/jedigo)) @@ -291,9 +292,9 @@ All definitions files include a header with the author and editors, so at some p * [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd)) * [node-form](https://github.com/rsamec/form) (by [Roman Samec](https://github.com/rsamec)) * [node-git](https://github.com/christkv/node-git) (by [vvakame](https://github.com/vvakame)) +* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov) and [Maxime LUCE](https://github.com/SomaticIT)) * [nodeunit](https://github.com/caolan/nodeunit) (by [Jeff Goddard](https://github.com/jedigo)) * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) -* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) * [node-tar](https://github.com/npm/node-tar) (by [Maxime LUCE](https://github.com/SomaticIT)) * [node-uuid](https://github.com/broofa/node-uuid) (by [Jeff May](https://github.com/jeffmay)) * [notify.js](https://github.com/alexgibson/notify.js) (by [soundTricker](https://github.com/soundTricker)) diff --git a/msnodesql/msnodesql-tests.ts b/msnodesql/msnodesql-tests.ts index 3f05f29aa..a27bf74e1 100644 --- a/msnodesql/msnodesql-tests.ts +++ b/msnodesql/msnodesql-tests.ts @@ -14,6 +14,22 @@ function test_streaming() { stmt.on('error', function (err) { console.log("We had an error :-( " + err); }); } +function test_callback() { + var conn_str = "Driver={SQL Server Native Client 11.0};Server={(local)\\SQLEXPRESS};Database={DBName};Trusted_Connection={Yes};"; + + sql.query(conn_str, "SELECT * FROM TestTable", (err, results) => { + if (err) { + console.error(err); + } + else if (results.length) { + console.log(results); + } + else { + console.log("No results"); + } + }); +} + function test_explicit() { var conn_str = "Driver={SQL Server Native Client 11.0};Server={(localdb)\\v11.0};Database={DBName};Trusted_Connection={Yes};"; diff --git a/msnodesql/msnodesql.d.ts b/msnodesql/msnodesql.d.ts index 39bf01fb8..77ce4d389 100644 --- a/msnodesql/msnodesql.d.ts +++ b/msnodesql/msnodesql.d.ts @@ -1,6 +1,6 @@ -// Type definitions for msnodesql 0.2 +// Type definitions for msnodesql 0.2.1 // Project: https://github.com/WindowsAzure/node-sqlserver -// Definitions by: Boris Yankov +// Definitions by: Boris Yankov , Maxime LUCE // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -11,18 +11,25 @@ declare module "msnodesql" { export function open(connectionString: string, callback?: OpenCallback): Connection; - export function query(connectionString: string, query: string, callback?: QueryCallback): StreamEvents; - export function query(connectionString: string, query: string, params: any[], callback?: QueryCallback): StreamEvents; + export function query(connectionString: string, query: string): StreamEvents; + export function query(connectionString: string, query: string, callback: QueryCallback): StreamEvents; + export function query(connectionString: string, query: string, params: any[]): StreamEvents; + export function query(connectionString: string, query: string, params: any[], callback: QueryCallback): StreamEvents; - export function queryRaw(connectionString: string, query: string, callback?: QueryRawCallback): StreamEvents; - export function queryRaw(connectionString: string, query: string, params: any[], callback?: QueryRawCallback): StreamEvents; + export function query(connectionString: string, query: string, callback: QueryCallback): StreamEvents; + export function query(connectionString: string, query: string, params: any[], callback: QueryCallback): StreamEvents; + + export function queryRaw(connectionString: string, query: string): StreamEvents; + export function queryRaw(connectionString: string, query: string, callback: QueryRawCallback): StreamEvents; + export function queryRaw(connectionString: string, query: string, params: any[]): StreamEvents; + export function queryRaw(connectionString: string, query: string, params: any[], callback: QueryRawCallback): StreamEvents; interface OpenCallback { (err?: Error, connection?: Connection): void; } - interface QueryCallback { - (err?: Error, results?: QueryRawResult, more?: boolean): void; + interface QueryCallback { + (err?: Error, results?: T[], more?: boolean): void; } interface QueryRawCallback { @@ -43,11 +50,18 @@ declare module "msnodesql" { } interface Connection { - queryRaw(query: string, callback?: QueryCallback): StreamEvents; - queryRaw(query: string, params: any[], callback?: QueryCallback): StreamEvents; + query(query: string): StreamEvents; + query(query: string, callback: QueryCallback): StreamEvents; + query(query: string, params: any[]): StreamEvents; + query(query: string, params: any[], callback: QueryCallback): StreamEvents; - query(query: string, callback?: QueryRawCallback): StreamEvents; - query(query: string, params: any[], callback?: QueryRawCallback): StreamEvents; + query(query: string, callback: QueryCallback): StreamEvents; + query(query: string, params: any[], callback: QueryCallback): StreamEvents; + + queryRaw(query: string): StreamEvents; + queryRaw(query: string, callback: QueryRawCallback): StreamEvents; + queryRaw(query: string, params: any[]): StreamEvents; + queryRaw(query: string, params: any[], callback: QueryRawCallback): StreamEvents; beginTransaction(callback?: ErrorCallback); commit(callback?: ErrorCallback);