mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 14:27:04 +00:00
Merge pull request #19152 from elliott-davis/add_wait_to_rethinkdb
Rethinkdb: Add wait option to table and db interfaces
This commit is contained in:
Vendored
+13
@@ -117,6 +117,17 @@ declare module "rethinkdb" {
|
||||
ssl?: TLSConnectionOptions;
|
||||
}
|
||||
|
||||
type waitFor = 'ready_for_outdated_reads' | 'ready_for_reads' | 'ready_for_writes';
|
||||
|
||||
interface WaitOptions {
|
||||
waitFor?: waitFor;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
interface WaitResult {
|
||||
ready: number;
|
||||
}
|
||||
|
||||
interface NoReplyWait {
|
||||
noreplyWait: boolean;
|
||||
}
|
||||
@@ -143,6 +154,7 @@ declare module "rethinkdb" {
|
||||
tableDrop(name: string): Operation<DropResult>;
|
||||
tableList(): Operation<string[]>;
|
||||
table(name: string, options?: GetTableOptions): Table;
|
||||
wait(WaitOptions?): WaitResult;
|
||||
}
|
||||
|
||||
interface TableOptions {
|
||||
@@ -233,6 +245,7 @@ declare module "rethinkdb" {
|
||||
get(key: string): Sequence; // primary key
|
||||
getAll(key: string, index?: Index): Sequence; // without index defaults to primary key
|
||||
getAll(...keys: string[]): Sequence;
|
||||
wait(WaitOptions?): WaitResult;
|
||||
}
|
||||
|
||||
interface Sequence extends Operation<Cursor>, Writeable {
|
||||
|
||||
@@ -22,7 +22,7 @@ r.connect({ host: "localhost", port: 28015 }, function(err: Error, conn: r.Conne
|
||||
|
||||
testDb.tableCreate("users").run(conn, function(err, stuff) {
|
||||
const users = testDb.table("users");
|
||||
|
||||
users.wait({waitFor: 'ready_for_reads'});
|
||||
users.insert({ name: "bob" }).run(conn, function() {
|
||||
});
|
||||
|
||||
@@ -55,6 +55,7 @@ r.connect({ host: "localhost", port: 28015 }).then(function(conn: r.Connection)
|
||||
console.log("HI", conn);
|
||||
|
||||
const testDb = r.db("test");
|
||||
testDb.wait({timeout: 1});
|
||||
|
||||
r.table("players").hasFields("games_won").run(conn).then(cursorCallback);
|
||||
r.table("players").hasFields({ "games_won": { "championships": true } }).run(conn).then(cursorCallback);
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
"index.d.ts",
|
||||
"rethinkdb-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user