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:
Nathan Shively-Sanders
2017-09-07 10:02:05 -07:00
committed by GitHub
3 changed files with 16 additions and 2 deletions
+13
View File
@@ -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 {
+2 -1
View File
@@ -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);
+1 -1
View File
@@ -19,4 +19,4 @@
"index.d.ts",
"rethinkdb-tests.ts"
]
}
}