diff --git a/rethinkdb/rethinkdb-tests.ts b/rethinkdb/rethinkdb-tests.ts
index e94e5271c..a6911e302 100644
--- a/rethinkdb/rethinkdb-tests.ts
+++ b/rethinkdb/rethinkdb-tests.ts
@@ -7,9 +7,9 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) {
var testDb = r.db('test')
testDb.tableCreate('users').run(conn, function(err, stuff) {
var users = testDb.table('users')
-
+
users.insert({name: "bob"}).run(conn, function() {})
-
+
users.filter(function(doc?) {
return doc("henry").eq("bob")
})
@@ -19,6 +19,24 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) {
})
+ })
+})
+
+// use promises instead of callbacks
+r.connect({host:"localhost", port: 28015}).then(function(conn) {
+ console.log("HI", conn)
+ var testDb = r.db('test')
+ testDb.tableCreate('users').run(conn).then(function(stuff) {
+ var users = testDb.table('users')
+
+ users.insert({name: "bob"}).run(conn, function() {})
+
+ users.filter(function(doc?) {
+ return doc("henry").eq("bob")
+ })
+ .between("james", "beth")
+ .limit(4)
+ .run(conn);
})
-})
\ No newline at end of file
+})
diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts
index 2c65a7cf4..22b721b9a 100644
--- a/rethinkdb/rethinkdb.d.ts
+++ b/rethinkdb/rethinkdb.d.ts
@@ -4,10 +4,11 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Reference: http://www.rethinkdb.com/api/#js
// TODO: Document manipulation and below
+///
declare module "rethinkdb" {
- export function connect(host:ConnectionOptions, cb:(err:Error, conn:Connection)=>void);
+ export function connect(host:ConnectionOptions, cb?:(err:Error, conn:Connection)=>void):Promise;
export function dbCreate(name:string):Operation;
export function dbDrop(name:string):Operation;
@@ -50,7 +51,7 @@ declare module "rethinkdb" {
interface Connection {
close();
- reconnect(cb:(err:Error, conn:Connection)=>void);
+ reconnect(cb?:(err:Error, conn:Connection)=>void):Promise;
use(dbName:string);
addListener(event:string, cb:Function);
on(event:string, cb:Function);
@@ -139,11 +140,11 @@ declare module "rethinkdb" {
}
interface ExpressionFunction {
- (doc:Expression):Expression;
+ (doc:Expression):Expression;
}
interface JoinFunction {
- (left:Expression, right:Expression):Expression;
+ (left:Expression, right:Expression):Expression;
}
interface ReduceFunction {
@@ -159,7 +160,7 @@ declare module "rethinkdb" {
interface UpdateOptions {
non_atomic: boolean;
durability: string; // 'soft'
- return_vals: boolean; // false
+ return_vals: boolean; // false
}
interface WriteResult {
@@ -193,7 +194,7 @@ declare module "rethinkdb" {
}
interface Expression extends Writeable, Operation {
- (prop:string):Expression;
+ (prop:string):Expression;
merge(query:Expression