[rethinkdb] Add missing promise types for cursor.next() (#45204)

This commit is contained in:
Tejesh Mehta 2020-06-12 11:14:58 -07:00 committed by GitHub
parent dcd7613ded
commit dd707289fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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[]>;

View File

@ -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();
})
});
});
});