Skip to content

Commit

Permalink
[rethinkdb] Add missing promise types for cursor.next() (DefinitelyTy…
Browse files Browse the repository at this point in the history
  • Loading branch information
tjmehta committed Jun 12, 2020
1 parent dcd7613 commit dd70728
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions types/rethinkdb/index.d.ts
Expand Up @@ -82,6 +82,8 @@ declare module "rethinkdb" {
each<T>(cb: (err: Error, row: T) => boolean, done?: () => void): void; // returning false stops iteration
next(cb: (err: Error, row: any) => void): void;
next<T>(cb: (err: Error, row: T) => void): void;
next(): Promise<any>;
next<T>(): Promise<T>;
toArray(cb: (err: Error, rows: any[]) => void): void;
toArray<T>(cb: (err: Error, rows: T[]) => void): void;
toArray(): Promise<any[]>;
Expand Down
11 changes: 8 additions & 3 deletions types/rethinkdb/rethinkdb-tests.ts
Expand Up @@ -98,9 +98,14 @@ r.connect({ host: "localhost", port: 28015 }).then(function(conn: r.Connection)
.limit(4)
.run(conn)
.then((cursor: r.Cursor) => {
cursor.toArray().then((rows: any[]) => {
console.log(rows);
});
return cursor.next().then((row) => {
console.log('first row', row);
return cursor.toArray();
}).then((rows) => {
console.log('all rows', rows);
}).then(() => {
return cursor.close();
})
});
});
});

0 comments on commit dd70728

Please sign in to comment.