GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing rethinkdb.com — ReQL command reference - RethinkDB JavaScript ReQL command reference
Looking for documentation for a community driver? Accessing ReQLrr → r The top-level ReQL namespace. Example: Set up your top-level namespace. Read more about this command → connectr.connect([options, ]callback) r.connect([host, ]callback) r.connect([options]) → promise r.connect([host]) → promise Create a new connection to the database server. Accepts the following options:
If the connection cannot be established, a Example: Open a connection using the default host and port, specifying the default database. If no callback is provided, a promise will be returned. Read more about this command → closeconn.close([{noreplyWait: true}, ]callback) conn.close([{noreplyWait: true}]) → promise Close an open connection. If no callback is provided, a promise will be returned. Example: Close an open connection, waiting for noreply writes to finish. Read more about this command → reconnectconn.reconnect([{noreplyWait: true}, ]callback) conn.reconnect([{noreplyWait: true}]) → promise Close and reopen a connection. If no callback is provided, a promise will be returned. Example: Cancel outstanding requests/queries that are no longer needed. Read more about this command → useconn.use(dbName) Change the default database on this connection. Example: Change the default database so that we don’t need to specify the database when referencing a table. Read more about this command → runquery.run(conn[, options], callback) query.run(conn[, options]) → promise Run a query on a connection. The callback will get either an error, a single JSON result, or a cursor, depending on the query. Example: Run a query on the connection Read more about this command → changesstream.changes([options]) → stream singleSelection.changes([options]) → stream Turn a query into a changefeed, an infinite stream of objects representing changes to the query’s results as they occur. A changefeed may return changes to a table or an individual document (a “point” changefeed). Commands such as Example: Subscribe to the changes on a table. Start monitoring the changefeed in one client: As these queries are performed in a second client, the first client would receive and print the following objects: Read more about this command → noreplyWaitconn.noreplyWait(callback) conn.noreplyWait() → promise
If no callback is provided, a promise will be returned. Example: We have previously run queries with the Read more about this command → serverconn.server(callback) conn.server() → promise Return information about the server being used by a connection. Example: Return server information. If no callback is provided, a promise will be returned. Read more about this command → EventEmitter (connection)connection.addListener(event, listener) connection.on(event, listener) connection.once(event, listener) connection.removeListener(event, listener) connection.removeAllListeners([event]) connection.setMaxListeners(n) connection.listeners(event) connection.emit(event, [arg1], [arg2], [...]) Connections implement the same interface as Node’s [EventEmitter][ee]. This allows you to listen for changes in connection state. Example: Monitor the connection state with events. Cursorsnextcursor.next(callback) array.next(callback) cursor.next() → promise array.next() → promise Get the next element in the cursor. Example: Retrieve the next element. Read more about this command → eachcursor.each(callback[, onFinishedCallback]) array.each(callback[, onFinishedCallback]) feed.each(callback) Lazily iterate over the result set one element at a time. The second callback is optional
and is called when the iteration stops (when there are no more rows or when the callback
returns Example: Let’s process all the elements! Read more about this command → eachAsyncsequence.eachAsync(function[, errorFunction]) → promise Lazily iterate over a cursor, array, or feed one element at a time. Example: Process all the elements in a stream, using Read more about this command → toArraycursor.toArray(callback) array.toArray(callback) cursor.toArray() → promise array.toArray() → promise Retrieve all results and pass them as an array to the given callback. Example: For small result sets it may be more convenient to process them at once as an array. Read more about this command → closecursor.close([callback]) cursor.close() → promise Close a cursor. Closing a cursor cancels the corresponding query and frees the memory associated with the open request. Example: Close a cursor. Read more about this command → EventEmitter (cursor)cursor.addListener(event, listener) cursor.on(event, listener) cursor.once(event, listener) cursor.removeListener(event, listener) cursor.removeAllListeners([event]) cursor.setMaxListeners(n) cursor.listeners(event) cursor.emit(event, [arg1], [arg2], [...]) Cursors and feeds implement the same interface as Node’s EventEmitter. Example: Broadcast all messages with socket.io. Manipulating databasesdbCreater.dbCreate(dbName) → object Create a database. A RethinkDB database is a collection of tables, similar to relational databases. Example: Create a database named ‘superheroes’. Read more about this command → dbDropr.dbDrop(dbName) → object Drop a database. The database, all its tables, and corresponding data will be deleted. Example: Drop a database named ‘superheroes’. Read more about this command → dbListr.dbList() → array List all database names in the system. The result is a list of strings. Example: List all databases. Manipulating tablestableCreatedb.tableCreate(tableName[, options]) → object r.tableCreate(tableName[, options]) → object Create a table. A RethinkDB table is a collection of JSON documents. Example: Create a table named ‘dc_universe’ with the default settings. Read more about this command → tableDropdb.tableDrop(tableName) → object Drop a table from a database. The table and all its data will be deleted. Example: Drop a table named ‘dc_universe’. Read more about this command → tableListdb.tableList() → array List all table names in a database. The result is a list of strings. Example: List all tables of the ‘test’ database. Read more about this command → indexCreatetable.indexCreate(indexName[, indexFunction][, {multi: false, geo: false}]) → object Create a new secondary index on a table. Secondary indexes improve the speed of many read queries at the slight cost of increased storage space and decreased write performance. For more information about secondary indexes, read the article “Using secondary indexes in RethinkDB.” Example: Create a simple index based on the field Read more about this command → indexDroptable.indexDrop(indexName) → object Delete a previously created secondary index of this table. Example: Drop a secondary index named ‘code_name’. Read more about this command → indexListtable.indexList() → array List all the secondary indexes of this table. Example: List the available secondary indexes for this table. Read more about this command → indexRenametable.indexRename(oldIndexName, newIndexName[, {overwrite: false}]) → object Rename an existing secondary index on a table. If the optional argument Example: Rename an index on the comments table. Read more about this command → indexStatustable.indexStatus([, index...]) → array Get the status of the specified indexes on this table, or the status of all indexes on this table if no indexes are specified. Example: Get the status of all the indexes on Read more about this command → indexWaittable.indexWait([, index...]) → array Wait for the specified indexes on this table to be ready, or for all indexes on this table to be ready if no indexes are specified. Example: Wait for all indexes on the table Read more about this command → setWriteHooktable.setWriteHook(function | binary | null) → object Sets the write hook on a table or overwrites it if one already exists. The Read more about this command → getWriteHooktable.getWriteHook() → null/object Gets the write hook of this table. If a write hook exists, the result is an object of the following form: Writing datainserttable.insert(object | [object1, object2, ...][, {durability: "hard", returnChanges: false, conflict: "error"}]) → object Insert documents into a table. Accepts a single document or an array of documents. Example: Insert a document into the table Read more about this command → updatetable.update(object | function[, {durability: "hard", returnChanges: false, nonAtomic: false}]) → object selection.update(object | function[, {durability: "hard", returnChanges: false, nonAtomic: false}]) → object singleSelection.update(object | function[, {durability: "hard", returnChanges: false, nonAtomic: false}]) → object Update JSON documents in a table. Accepts a JSON document, a ReQL expression, or a combination of the two. Example: Update the status of the post with Read more about this command → replacetable.replace(object | function[, {durability: "hard", returnChanges: false, nonAtomic: false}]) → object selection.replace(object | function[, {durability: "hard", returnChanges: false, nonAtomic: false}]) → object singleSelection.replace(object | function[, {durability: "hard", returnChanges: false, nonAtomic: false}]) → object Replace documents in a table. Accepts a JSON document or a ReQL expression, and replaces the original document with the new one. The new document must have the same primary key as the original document. Example: Replace the document with the primary key Read more about this command → deletetable.delete([{durability: "hard", returnChanges: false}]) → object selection.delete([{durability: "hard", returnChanges: false}]) → object singleSelection.delete([{durability: "hard", returnChanges: false}]) → object Delete one or more documents from a table. Example: Delete a single document from the table Read more about this command → synctable.sync() → object
Example: After having updated multiple heroes with soft durability, we now want to wait until these changes are persisted. Selecting datadbr.db(dbName) → db Reference a database. Example: Explicitly specify a database for a query. Read more about this command → tabledb.table(name[, {readMode: 'single', identifierFormat: 'name'}]) → table Return all documents in a table. Other commands may be chained after Example: Return all documents in the table ‘marvel’ of the default database. Read more about this command → gettable.get(key) → singleRowSelection Get a document by primary key. Example: Find a document by UUID. Read more about this command → getAlltable.getAll([key, key2...], [, {index:'id'}]) → selection Get all documents where the given value matches the value of the requested index. Example: Secondary index keys are not guaranteed to be unique so we cannot query via get when using a secondary index. Read more about this command → betweentable.between(lowerKey, upperKey[, options]) → table_slice table_slice.between(lowerKey, upperKey[, options]) → table_slice Get all documents between two keys. Accepts three optional arguments: Example: Find all users with primary key >= 10 and < 20 (a normal half-open interval). Read more about this command → filterselection.filter(predicate_function[, {default: false}]) → selection stream.filter(predicate_function[, {default: false}]) → stream array.filter(predicate_function[, {default: false}]) → array Return all the elements in a sequence for which the given predicate is true. The return value of Example: Get all users who are 30 years old. The predicate JoinsinnerJoinsequence.innerJoin(otherSequence, predicate_function) → stream array.innerJoin(otherSequence, predicate_function) → array Returns an inner join of two sequences. Example: Return a list of all matchups between Marvel and DC heroes in which the DC hero could beat the Marvel hero in a fight. Read more about this command → outerJoinsequence.outerJoin(otherSequence, predicate_function) → stream array.outerJoin(otherSequence, predicate_function) → array Returns a left outer join of two sequences. The returned sequence represents a union of the left-hand sequence and the right-hand sequence: all documents in the left-hand sequence will be returned, each matched with a document in the right-hand sequence if one satisfies the predicate condition. In most cases, you will want to follow the join with zip to combine the left and right results. Example: Return a list of all Marvel heroes, paired with any DC heroes who could beat them in a fight. (Compare this to an innerJoin with the same inputs and predicate, which would return a list only of the matchups in which the DC hero has the higher strength.) Read more about this command → eqJoinsequence.eqJoin(leftField, rightTable[, {index: 'id', ordered: false}]) → sequence sequence.eqJoin(function, rightTable[, {index: 'id', ordered: false}]) → sequence Join tables using a field or function on the left-hand sequence matching primary keys or secondary indexes on the right-hand table. Example: Match players with the games they’ve played against one another. Join these tables using This will return a result set such as the following: Read more about this command → zipstream.zip() → stream array.zip() → array Used to ‘zip’ up the result of a join by merging the ‘right’ fields into ‘left’ fields of each member of the sequence. Example: ‘zips up’ the sequence by merging the left and right fields produced by a join. Transformationsmapsequence1.map([sequence2, ...], function) → stream array1.map([array2, ...], function) → array r.map(sequence1[, sequence2, ...], function) → stream r.map(array1[, array2, ...], function) → array Transform each element of one or more sequences by applying a mapping function to them. If Example: Return the first five squares. Read more about this command → withFieldssequence.withFields([selector1, selector2...]) → stream array.withFields([selector1, selector2...]) → array Plucks one or more attributes from a sequence of objects, filtering out any objects in the sequence that do not have the specified fields. Functionally, this is identical to hasFields followed by pluck on a sequence. Example: Get a list of users and their posts, excluding any users who have not made any posts. Existing table structure: Command and output: Read more about this command → concatMapstream.concatMap(function) → stream array.concatMap(function) → array Concatenate one or more elements into a single sequence using a mapping function. Example: Construct a sequence of all monsters defeated by Marvel heroes. The field “defeatedMonsters” is an array of one or more monster names. Read more about this command → orderBytable.orderBy([key | function...], {index: index_name}) → table_slice selection.orderBy(key | function[, ...]) → selection<array> sequence.orderBy(key | function[, ...]) → array Sort the sequence by document values of the given key(s). To specify
the ordering, wrap the attribute with either Example: Order all the posts using the index Read more about this command → skipsequence.skip(n) → stream array.skip(n) → array Skip a number of elements from the head of the sequence. Example: Here in conjunction with orderBy we choose to ignore the most successful heroes. Read more about this command → limitsequence.limit(n) → stream array.limit(n) → array End the sequence after the given number of elements. Example: Only so many can fit in our Pantheon of heroes. Read more about this command → sliceselection.slice(startOffset[, endOffset, {leftBound:'closed', rightBound:'open'}]) → selection stream.slice(startOffset[, endOffset, {leftBound:'closed', rightBound:'open'}]) → stream array.slice(startOffset[, endOffset, {leftBound:'closed', rightBound:'open'}]) → array binary.slice(startOffset[, endOffset, {leftBound:'closed', rightBound:'open'}]) → binary string.slice(startOffset[, endOffset, {leftBound:'closed', rightBound:'open'}]) → string Return the elements of a sequence within the specified range. Example: Return the fourth, fifth and sixth youngest players. (The youngest player is at index 0, so those are elements 3–5.) Read more about this command → nthsequence.nth(index) → object selection.nth(index) → selection<object> Get the nth element of a sequence, counting from zero. If the argument is negative, count from the last element. Example: Select the second element in the array. Read more about this command → offsetsOfsequence.offsetsOf(datum | predicate_function) → array Get the indexes of an element in a sequence. If the argument is a predicate, get the indexes of all elements matching it. Example: Find the position of the letter ‘c’. Read more about this command → isEmptysequence.isEmpty() → bool Test if a sequence is empty. Example: Are there any documents in the marvel table? Read more about this command → unionstream.union(sequence[, sequence, ...][, {interleave: true}]) → stream array.union(sequence[, sequence, ...][, {interleave: true}]) → array r.union(stream, sequence[, sequence, ...][, {interleave: true}]) → stream r.union(array, sequence[, sequence, ...][, {interleave: true}]) → array Merge two or more sequences. Example: Construct a stream of all heroes. Read more about this command → samplesequence.sample(number) → selection stream.sample(number) → array array.sample(number) → array Select a given number of elements from a sequence with uniform random distribution. Selection is done without replacement. Example: Select 3 random heroes. Aggregationgroupsequence.group(field | function..., [{index: <indexname>, multi: false}]) → grouped_stream r.group(sequence, field | function..., [{index: <indexname>, multi: false}]) → grouped_stream Takes a stream and partitions it into multiple groups based on the fields or functions provided. Example: Group games by player. Read more about this command → ungroupgrouped_stream.ungroup() → array grouped_data.ungroup() → array Takes a grouped stream or grouped data and turns it into an array of
objects representing the groups. Any commands chained after Example: What is the maximum number of points scored by each player, with the highest scorers first? Read more about this command → reducesequence.reduce(function) → value r.reduce(sequence, function) → value Produce a single value from a sequence through repeated application of a reduction function. Example: Return the number of documents in the table A shorter way to execute this query is to use count. Read more about this command → foldsequence.fold(base, function) → value sequence.fold(base, function, {emit: function[, finalEmit: function]}) → sequence Apply a function to a sequence in order, maintaining state via an accumulator. The Example: Concatenate words from a list. (This example could be implemented with Read more about this command → countsequence.count([value | predicate_function]) → number binary.count() → number string.count() → number object.count() → number r.count(sequence | binary | string | object[, predicate_function]) → number Counts the number of elements in a sequence or key/value pairs in an object, or returns the size of a string or binary object. Example: Count the number of users. Read more about this command → sumsequence.sum([field | function]) → number r.sum(sequence, [field | function]) → number Sums all the elements of a sequence. If called with a field name,
sums all the values of that field in the sequence, skipping elements
of the sequence that lack that field. If called with a function,
calls that function on every element of the sequence and sums the
results, skipping elements of the sequence where that function returns
Example: What’s 3 + 5 + 7? Read more about this command → avgsequence.avg([field | function]) → number r.avg(sequence, [field | function]) → number Averages all the elements of a sequence. If called with a field name,
averages all the values of that field in the sequence, skipping
elements of the sequence that lack that field. If called with a
function, calls that function on every element of the sequence and
averages the results, skipping elements of the sequence where that
function returns Example: What’s the average of 3, 5, and 7? Read more about this command → minsequence.min(field | function) → element sequence.min({index: <indexname>}) → element r.min(sequence, field | function) → element r.min(sequence, {index: <indexname>}) → element Finds the minimum element of a sequence. Example: Return the minimum value in the list Read more about this command → maxsequence.max(field | function) → element sequence.max({index: <indexname>}) → element r.max(sequence, field | function) → element r.max(sequence, {index: <indexname>}) → element Finds the maximum element of a sequence. Example: Return the maximum value in the list Read more about this command → distinctsequence.distinct() → array table.distinct([{index: <indexname>}]) → stream r.distinct(sequence) → array r.distinct(table, [{index: <indexname>}]) → stream Removes duplicates from elements in a sequence. Example: Which unique villains have been vanquished by Marvel heroes? Read more about this command → containssequence.contains([value | predicate_function, ...]) → bool r.contains(sequence, [value | predicate_function, ...]) → bool When called with values, returns Example: Has Iron Man ever fought Superman? Document manipulationrowr.row → value Returns the currently visited document. Example: Get all users whose age is greater than 5. Read more about this command → plucksequence.pluck([selector1, selector2...]) → stream array.pluck([selector1, selector2...]) → array object.pluck([selector1, selector2...]) → object singleSelection.pluck([selector1, selector2...]) → object Plucks out one or more attributes from either an object or a sequence of objects (projection). Example: We just need information about IronMan’s reactor and not the rest of the document. Read more about this command → withoutsequence.without([selector1, selector2...]) → stream array.without([selector1, selector2...]) → array singleSelection.without([selector1, selector2...]) → object object.without([selector1, selector2...]) → object The opposite of pluck; takes an object or a sequence of objects, and returns them with the specified paths removed. Example: Since we don’t need it for this computation we’ll save bandwidth and leave out the list of IronMan’s romantic conquests. Read more about this command → mergesingleSelection.merge([object | function, object | function, ...]) → object object.merge([object | function, object | function, ...]) → object sequence.merge([object | function, object | function, ...]) → stream array.merge([object | function, object | function, ...]) → array Merge two or more objects together to construct a new object with properties from all. When there is a conflict between field names, preference is given to fields in the rightmost object in the argument list. Example: Equip Thor for battle. Read more about this command → appendarray.append(value) → array Append a value to an array. Example: Retrieve Iron Man’s equipment list with the addition of some new boots. Read more about this command → prependarray.prepend(value) → array Prepend a value to an array. Example: Retrieve Iron Man’s equipment list with the addition of some new boots. Read more about this command → differencearray.difference(array) → array Remove the elements of one array from another array. Example: Retrieve Iron Man’s equipment list without boots. Read more about this command → setInsertarray.setInsert(value) → array Add a value to an array and return it as a set (an array with distinct values). Example: Retrieve Iron Man’s equipment list with the addition of some new boots. Read more about this command → setUnionarray.setUnion(array) → array Add a several values to an array and return it as a set (an array with distinct values). Example: Retrieve Iron Man’s equipment list with the addition of some new boots and an arc reactor. Read more about this command → setIntersectionarray.setIntersection(array) → array Intersect two arrays returning values that occur in both of them as a set (an array with distinct values). Example: Check which pieces of equipment Iron Man has from a fixed list. Read more about this command → setDifferencearray.setDifference(array) → array Remove the elements of one array from another and return them as a set (an array with distinct values). Example: Check which pieces of equipment Iron Man has, excluding a fixed list. Read more about this command → () (bracket)sequence(attr) → sequence singleSelection(attr) → value object(attr) → value array(index) → value Get a single field from an object. If called on a sequence, gets that field from every object in the sequence, skipping objects that lack it. Example: What was Iron Man’s first appearance in a comic? Read more about this command → getFieldsequence.getField(attr) → sequence singleSelection.getField(attr) → value object.getField(attr) → value Get a single field from an object. If called on a sequence, gets that field from every object in the sequence, skipping objects that lack it. Example: What was Iron Man’s first appearance in a comic? Read more about this command → hasFieldssequence.hasFields([selector1, selector2...]) → stream array.hasFields([selector1, selector2...]) → array object.hasFields([selector1, selector2...]) → boolean Test if an object has one or more fields. An object has a field if it has that key and the key has a non-null value. For instance, the object Example: Return the players who have won games. Read more about this command → insertAtarray.insertAt(offset, value) → array Insert a value in to an array at a given index. Returns the modified array. Example: Hulk decides to join the avengers. Read more about this command → spliceAtarray.spliceAt(offset, array) → array Insert several values in to an array at a given index. Returns the modified array. Example: Hulk and Thor decide to join the avengers. Read more about this command → deleteAtarray.deleteAt(offset [,endOffset]) → array Remove one or more elements from an array at a given index. Returns the modified array. (Note: Example: Delete the second element of an array. Read more about this command → changeAtarray.changeAt(offset, value) → array Change a value in an array at a given index. Returns the modified array. Example: Bruce Banner hulks out. Read more about this command → keyssingleSelection.keys() → array object.keys() → array Return an array containing all of an object’s keys. Note that the keys will be sorted as described in ReQL data types (for strings, lexicographically). Example: Get all the keys from a table row. Read more about this command → valuessingleSelection.values() → array object.values() → array Return an array containing all of an object’s values. Example: Get all of the values from a table row. Read more about this command → literalr.literal(object) → special Replace an object in a field instead of merging it with an existing object in a Example: Replace one nested document with another rather than merging the fields. Read more about this command → objectr.object([key, value,]...) → object Creates an object from a list of key-value pairs, where the keys must
be strings. Example: Create a simple object. Result: String manipulationmatchstring.match(regexp) → null/object Matches against a regular expression. If there is a match, returns an object with the fields:
If no match is found, returns Example: Get all users whose name starts with “A”. Because Read more about this command → splitstring.split([separator, [max_splits]]) → array Splits a string into substrings. Splits on whitespace when called
with no arguments. When called with a separator, splits on that
separator. When called with a separator and a maximum number of
splits, splits on that separator at most Example: Split on whitespace. Result: Read more about this command → upcasestring.upcase() → string Uppercases a string. Example: Result: Note: Read more about this command → downcasestring.downcase() → string Lowercases a string. Example: Result: Note: Math and logicaddvalue.add(value[, value, ...]) → value time.add(number[, number, ...]) → time Sum two or more numbers, or concatenate two or more strings or arrays. Example: It’s as easy as 2 + 2 = 4. Read more about this command → subnumber.sub(number[, number, ...]) → number time.sub(number[, number, ...]) → time time.sub(time) → number Subtract two numbers. Example: It’s as easy as 2 - 2 = 0. Read more about this command → mulnumber.mul(number[, number, ...]) → number array.mul(number[, number, ...]) → array Multiply two numbers, or make a periodic array. Example: It’s as easy as 2 * 2 = 4. Read more about this command → divnumber.div(number[, number ...]) → number Divide two numbers. Example: It’s as easy as 2 / 2 = 1. Read more about this command → modnumber.mod(number) → number Example: It’s as easy as 2 % 2 = 0. Read more about this command → andbool.and([bool, bool, ...]) → bool r.and([bool, bool, ...]) → bool Compute the logical “and” of one or more values. Example: Return whether both Read more about this command → orbool.or([bool, bool, ...]) → bool r.or([bool, bool, ...]) → bool Compute the logical “or” of one or more values. Example: Return whether either Read more about this command → eqvalue.eq(value[, value, ...]) → bool Test if two or more values are equal. Example: See if a user’s Read more about this command → nevalue.ne(value[, value, ...]) → bool Test if two or more values are not equal. Example: See if a user’s Read more about this command → gtvalue.gt(value[, value, ...]) → bool Compare values, testing if the left-hand value is greater than the right-hand. Example: Test if a player has scored more than 10 points. Read more about this command → gevalue.ge(value[, value, ...]) → bool Compare values, testing if the left-hand value is greater than or equal to the right-hand. Example: Test if a player has scored 10 points or more. Read more about this command → ltvalue.lt(value[, value, ...]) → bool Compare values, testing if the left-hand value is less than the right-hand. Example: Test if a player has scored less than 10 points. Read more about this command → levalue.le(value[, value, ...]) → bool Compare values, testing if the left-hand value is less than or equal to the right-hand. Example: Test if a player has scored 10 points or less. Read more about this command → notbool.not() → bool not(bool) → bool Compute the logical inverse (not) of an expression. Example: Not true is false. These evaluate to Read more about this command → bitAndr.bitAnd(number) → number r.bitAnd(number[, number, ...]) → number Compute the arithmetic “and” of one or more values. Example: Compute the arithmetic “and” of Read more about this command → bitOrr.bitOr(number) → number r.bitOr(number[, number, ...]) → number Compute the arithmetic “or” of one or more values. Example: Compute the arithmetic “or” of Read more about this command → bitXorr.bitXor(number) → number r.bitXor(number[, number, ...]) → number Compute the arithmetic “and” of one or more values. Example: Compute the arithmetic “and” of Read more about this command → bitNotr.bitNot() → number Compute the arithmetic inverse (not) of an expression. Example: Negate the arithmetice expression Read more about this command → bitSalr.bitSal(number) → number r.bitSal(number[, number, ...]) → number Compute the left arithmetic shift (left logical shift) of one or more values. Example: Compute the left arithmetic shift of Read more about this command → bitSarr.bitSar(number) → number r.bitSar(number[, number, ...]) → number Compute the right arithmetic shift of one or more values. Example: Compute the right arithmetic shift of Read more about this command → randomr.random() → number r.random(number[, number], {float: true}) → number r.random(integer[, integer]) → integer Generate a random number between given (or implied) bounds. Example: Generate a random number in the range Read more about this command → roundr.round(number) → number number.round() → number Rounds the given value to the nearest whole integer. Example: Round 12.345 to the nearest integer. The Read more about this command → ceilr.ceil(number) → number number.ceil() → number Rounds the given value up, returning the smallest integer value greater than or equal to the given value (the value’s ceiling). Example: Return the ceiling of 12.345. The Read more about this command → floorr.floor(number) → number number.floor() → number Rounds the given value down, returning the largest integer value less than or equal to the given value (the value’s floor). Example: Return the floor of 12.345. The Dates and timesnowr.now() → time Return a time object representing the current time in UTC. The command now() is computed once when the server receives the query, so multiple instances of r.now() will always return the same time inside a query. Example: Add a new user with the time at which he subscribed. Read more about this command → timer.time(year, month, day[, hour, minute, second], timezone) → time Create a time object for a specific time. Example: Update the birthdate of the user “John” to November 3rd, 1986 UTC. Read more about this command → epochTimer.epochTime(number) → time Create a time object based on seconds since epoch. The first argument is a double and will be rounded to three decimal places (millisecond-precision). Example: Update the birthdate of the user “John” to November 3rd, 1986. Read more about this command → ISO8601r.ISO8601(string[, {defaultTimezone:''}]) → time Create a time object based on an ISO 8601 date-time string (e.g. ‘2013-01-01T01:01:01+00:00’). RethinkDB supports all valid ISO 8601 formats except for week dates. Read more about the ISO 8601 format at Wikipedia. Example: Update the time of John’s birth. Read more about this command → inTimezonetime.inTimezone(timezone) → time Return a new time object with a different timezone. While the time stays the same, the results returned by methods such as hours() will change since they take the timezone into account. The timezone argument has to be of the ISO 8601 format. Example: Hour of the day in San Francisco (UTC/GMT -8, without daylight saving time). Read more about this command → timezonetime.timezone() → string Return the timezone of the time object. Example: Return all the users in the “-07:00” timezone. Read more about this command → duringtime.during(startTime, endTime[, {leftBound: "closed", rightBound: "open"}]) → bool Return whether a time is between two other times. Example: Retrieve all the posts that were posted between December 1st, 2013 (inclusive) and December 10th, 2013 (exclusive). Read more about this command → datetime.date() → time Return a new time object only based on the day, month and year (ie. the same day at 00:00). Example: Retrieve all the users whose birthday is today. Read more about this command → timeOfDaytime.timeOfDay() → number Return the number of seconds elapsed since the beginning of the day stored in the time object. Example: Retrieve posts that were submitted before noon. Read more about this command → yeartime.year() → number Return the year of a time object. Example: Retrieve all the users born in 1986. Read more about this command → monthtime.month() → number Return the month of a time object as a number between 1 and 12. For your convenience, the terms r.january, r.february etc. are defined and map to the appropriate integer. Example: Retrieve all the users who were born in November. Read more about this command → daytime.day() → number Return the day of a time object as a number between 1 and 31. Example: Return the users born on the 24th of any month. Read more about this command → dayOfWeektime.dayOfWeek() → number Return the day of week of a time object as a number between 1 and 7 (following ISO 8601 standard). For your convenience, the terms r.monday, r.tuesday etc. are defined and map to the appropriate integer. Example: Return today’s day of week. Read more about this command → dayOfYeartime.dayOfYear() → number Return the day of the year of a time object as a number between 1 and 366 (following ISO 8601 standard). Example: Retrieve all the users who were born the first day of a year. Read more about this command → hourstime.hours() → number Return the hour in a time object as a number between 0 and 23. Example: Return all the posts submitted after midnight and before 4am. Read more about this command → minutestime.minutes() → number Return the minute in a time object as a number between 0 and 59. Example: Return all the posts submitted during the first 10 minutes of every hour. Read more about this command → secondstime.seconds() → number Return the seconds in a time object as a number between 0 and 59.999 (double precision). Example: Return the post submitted during the first 30 seconds of every minute. Read more about this command → toISO8601time.toISO8601() → string Convert a time object to a string in ISO 8601 format. Example: Return the current ISO 8601 time. Read more about this command → toEpochTimetime.toEpochTime() → number Convert a time object to its epoch time. Example: Return the current time in seconds since the Unix Epoch with millisecond-precision. Control structuresargsr.args(array) → special
Example: Get Alice and Bob from the table Read more about this command → binaryr.binary(data) → binary Encapsulate binary data within a query. Example: Save an avatar image to a existing user record. Read more about this command → doany.do(function) → any r.do([args]*, function) → any any.do(expr) → any r.do([args]*, expr) → any Call an anonymous function using return values from other ReQL commands or queries as arguments. Example: Compute a golfer’s net score for a game. Read more about this command → branchr.branch(test, true_action[, test2, test2_action, ...], false_action) → any test.branch(true_action[, test2, test2_action, ...], false_action) → any Perform a branching conditional equivalent to The Example: Test the value of x. Read more about this command → forEachsequence.forEach(write_function) → object Loop over a sequence, evaluating the given write query for each element. Example: Now that our heroes have defeated their villains, we can safely remove them from the villain table. Read more about this command → ranger.range() → stream r.range([startValue, ]endValue) → stream Generate a stream of sequential integers in a specified range. Example: Return a four-element range of Read more about this command → errorr.error(message) → error Throw a runtime error. If called with no arguments inside the second argument to Example: Iron Man can’t possibly have lost a battle: Read more about this command → defaultvalue.default(default_value | function) → any sequence.default(default_value | function) → any Provide a default value in case of non-existence errors. The Example: Retrieve the titles and authors of the table Read more about this command → exprr.expr(value) → value Construct a ReQL JSON object from a native object. Example: Objects wrapped with Read more about this command → jsr.js(jsString[, {timeout: <number>}]) → value Create a javascript expression. Example: Concatenate two strings using JavaScript. Read more about this command → coerceTosequence.coerceTo('array') → array value.coerceTo('string') → string string.coerceTo('number') → number array.coerceTo('object') → object sequence.coerceTo('object') → object object.coerceTo('array') → array binary.coerceTo('string') → string string.coerceTo('binary') → binary Convert a value of one type into another. Example: Coerce a stream to an array to store its output in a field. (A stream cannot be stored in a field directly.) Read more about this command → typeOfany.typeOf() → string Gets the type of a ReQL query’s return value. Example: Get the type of a string. Read more about this command → infoany.info() → object r.info(any) → object Get information about a ReQL value. Example: Get information about a table such as primary key, or cache size. Read more about this command → jsonr.json(json_string) → value Parse a JSON string on the server. Example: Send an array to the server. Read more about this command → toJsonString, toJSONvalue.toJsonString() → string value.toJSON() → string Convert a ReQL value or object to a JSON string. You may use either Example: Get a ReQL document as a JSON string. Read more about this command → httpr.http(url[, options]) → value r.http(url[, options]) → stream Retrieve data from the specified URL over HTTP. The return type depends on the Example: Perform an HTTP Read more about this command → uuidr.uuid([string]) → string Return a UUID (universally unique identifier), a string that can be used as a unique ID. If a string is passed to Example: Generate a UUID. Geospatial commandscircler.circle([longitude, latitude], radius[, {numVertices: 32, geoSystem: 'WGS84', unit: 'm', fill: true}]) → geometry r.circle(point, radius[, {numVertices: 32, geoSystem: 'WGS84', unit: 'm', fill: true}]) → geometry Construct a circular line or polygon. A circle in RethinkDB is a polygon or line approximating a circle of a given radius around a given center, consisting of a specified number of vertices (default 32). Example: Define a circle. Read more about this command → distancegeometry.distance(geometry[, {geoSystem: 'WGS84', unit: 'm'}]) → number r.distance(geometry, geometry[, {geoSystem: 'WGS84', unit: 'm'}]) → number Compute the distance between a point and another geometry object. At least one of the geometry objects specified must be a point. Example: Compute the distance between two points on the Earth in kilometers. Read more about this command → fillline.fill() → polygon Convert a Line object into a Polygon object. If the last point does not specify the same coordinates as the first point, Example: Create a line object and then convert it to a polygon. Read more about this command → geojsonr.geojson(geojson) → geometry Convert a GeoJSON object to a ReQL geometry object. Example: Convert a GeoJSON object to a ReQL geometry object. Read more about this command → toGeojsongeometry.toGeojson() → object Convert a ReQL geometry object to a GeoJSON object. Example: Convert a ReQL geometry object to a GeoJSON object. Read more about this command → getIntersectingtable.getIntersecting(geometry, {index: 'indexname'}) → selection<stream> Get all documents where the given geometry object intersects the geometry object of the requested geospatial index. Example: Which of the locations in a list of parks intersect Read more about this command → getNearesttable.getNearest(point, {index: 'indexname'[, maxResults: 100, maxDist: 100000, unit: 'm', geoSystem: 'WGS84']}) → array Return a list of documents closest to a specified point based on a geospatial index, sorted in order of increasing distance. Example: Return a list of the closest 25 enemy hideouts to the secret base. Read more about this command → includessequence.includes(geometry) → sequence geometry.includes(geometry) → bool Tests whether a geometry object is completely contained within another. When applied to a sequence of geometry objects, Example: Is Read more about this command → intersectssequence.intersects(geometry) → sequence geometry.intersects(geometry) → bool r.intersects(sequence, geometry) → sequence r.intersects(geometry, geometry) → bool Tests whether two geometry objects intersect with one another. When applied to a sequence of geometry objects, Example: Is Read more about this command → liner.line([lon1, lat1], [lon2, lat2], ...) → line r.line(point1, point2, ...) → line Construct a geometry object of type Line. The line can be specified in one of two ways:
Example: Define a line. Read more about this command → pointr.point(longitude, latitude) → point Construct a geometry object of type Point. The point is specified by two floating point numbers, the longitude (−180 to 180) and latitude (−90 to 90) of the point on a perfect sphere. See Geospatial support for more information on ReQL’s coordinate system. Example: Define a point. Read more about this command → polygonr.polygon([lon1, lat1], [lon2, lat2], [lon3, lat3], ...) → polygon r.polygon(point1, point2, point3, ...) → polygon Construct a geometry object of type Polygon. The Polygon can be specified in one of two ways:
Example: Define a polygon. Read more about this command → polygonSubpolygon1.polygonSub(polygon2) → polygon Use Example: Define a polygon with a hole punched in it. Administrationgrantr.grant("username", {permission: bool[, ...]}) → object db.grant("username", {permission: bool[, ...]}) → object table.grant("username", {permission: bool[, ...]}) → object Grant or deny access permissions for a user account, globally or on a per-database or per-table basis. Example: Grant the Read more about this command → configtable.config() → selection<object> database.config() → selection<object> Query (read and/or update) the configurations for individual tables or databases. Example: Get the configuration for the Read more about this command → rebalancetable.rebalance() → object database.rebalance() → object Rebalances the shards of a table. When called on a database, all the tables in that database will be rebalanced. Example: Rebalance a table. Read more about this command → reconfiguretable.reconfigure({shards: <s>, replicas: <r>[, primaryReplicaTag: <t>, dryRun: false, nonvotingReplicaTags: null}]) → object database.reconfigure({shards: <s>, replicas: <r>[, primaryReplicaTag: <t>, dryRun: false, nonvotingReplicaTags: null}]) → object table.reconfigure(emergencyRepair: <option>, dryRun: false) → object Reconfigure a table’s sharding and replication. Example: Reconfigure a table. Read more about this command → statustable.status() → selection<object> Return the status of a table. Example: Get a table’s status. Read more about this command → waittable.wait([{waitFor: 'all_replicas_ready', timeout: <sec>}]) → object database.wait([{waitFor: 'all_replicas_ready', timeout: <sec>}]) → object r.wait(table | database, [{waitFor: 'all_replicas_ready', timeout: <sec>}]) → object Wait for a table or all the tables in a database to be ready. A table may be temporarily unavailable after creation, rebalancing or reconfiguring. The Example: Wait on a table to be ready. Improve this docHelp us improve this document.
Get more helpWe always welcome suggestions on how to improve our documentation, or specific ReQL questions.
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |