mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[cassandra-driver] add promise API
This commit is contained in:
@@ -4,6 +4,11 @@ import * as util from 'util';
|
||||
var client = new cassandra.Client({ contactPoints: ['h1', 'h2'], keyspace: 'ks1'});
|
||||
|
||||
var query = 'SELECT email, last_name FROM user_profiles WHERE key=?';
|
||||
client.execute(query, ['guy'], function(err: any, result: any) {
|
||||
client.execute(query, ['guy'], function(err, result) {
|
||||
console.log('got user profile with email ' + result.rows[0].email);
|
||||
});
|
||||
});
|
||||
|
||||
client.execute(query, [ 'guy' ], { prepare: true }).then(
|
||||
(result) => console.log(result.first().email),
|
||||
(error) => console.log(error)
|
||||
);
|
||||
|
||||
14
types/cassandra-driver/index.d.ts
vendored
14
types/cassandra-driver/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for nodejs-driver v0.8.2
|
||||
// Type definitions for cassandra-driver v3.2.2
|
||||
// Project: https://github.com/datastax/nodejs-driver
|
||||
// Definitions by: Marc Fisher <https://github.com/Svjard>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -378,6 +378,7 @@ export namespace types {
|
||||
values(): Array<{ [key: string]: any; }>;
|
||||
keys(): Array<string>;
|
||||
forEach(callback: Callback): void;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface TimeUuidStatic {
|
||||
@@ -506,10 +507,17 @@ export interface Client extends events.EventEmitter {
|
||||
metadata: metadata.Metadata;
|
||||
|
||||
batch(queries: Array<string> | Array<{ query: string, params?: any }>, options: QueryOptions, callback: ResultCallback): void;
|
||||
batch(queries: Array<string> | Array<{ query: string, params?: any }>, callback: ResultCallback): void;
|
||||
batch(queries: Array<string> | Array<{ query: string, params?: any }>, options?: QueryOptions): Promise<types.ResultSet>;
|
||||
|
||||
connect(callback: Callback): void;
|
||||
eachRow(query: string, params?: any, options?: QueryOptions, rowCallback?: Callback, callback?: Callback): void;
|
||||
execute(query: string, params?: any, callback?: ResultCallback): void;
|
||||
execute(query: string, params?: any, options?: QueryOptions, callback?: ResultCallback): void;
|
||||
|
||||
execute(query: string, params: any, options: QueryOptions, callback: ResultCallback): void;
|
||||
execute(query: string, params: any, callback: ResultCallback): void;
|
||||
execute(query: string, callback: ResultCallback): void;
|
||||
execute(query: string, params?: any, options?: QueryOptions): Promise<types.ResultSet>;
|
||||
|
||||
getReplicas(keyspace: string, token: Buffer): Array<any>; // TODO: Should this be a more explicit return?
|
||||
shutdown(callback?: Callback): void;
|
||||
stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): NodeJS.ReadableStream;
|
||||
|
||||
Reference in New Issue
Block a user