Skip to content

Go ReQL command reference

Daniel Cannon edited this page May 16, 2015 · 2 revisions

Accessing ReQL

All ReQL queries begin from the top-level module.

  • Connect - Connect creates a new database session. To view the available connection options see ConnectOpts.
  • Close - Close closes the session
  • Reconnect - Reconnect closes and re-opens a session.
  • Run - Run runs a query using the given connection.
  • RunWrite - RunWrite runs a query using the given connection but unlike Run automatically scans the result into a variable of type WriteResponss. This function should be used if you are running a write query (such as Insert, Update, TableCreate, etc...)
  • Exec - Exec runs the query but does not return the result.
  • NoReplyWait - NoReplyWait ensures that previous queries with the noreply flag have been processed by the server. Note that this guarantee only applies to queries run on the given connection.

Cursors

  • Next - Next retrieves the next document from the result set, blocking if necessary.
  • All - All retrieves all documents from the result set into the provided slice and closes the cursor.
  • One - One retrieves a single document from the result set into the provided slice and closes the cursor.
  • Listen - Listen listens for rows from the database and sends the result onto the given channel
  • IsNil - IsNil tests if the current row is nil.
  • Err - Err returns nil if no errors happened during iteration, or the actual error otherwise.
  • Close - Close closes the cursor, preventing further enumeration.

Manipulating databases

Manipulating tables

Writing data

Selecting data

Joins

Transformations

Aggregation

Document manipulation

String manipulation

Math and logic

Dates and times

Control structures

  • Args - Args is a special term that’s used to splice an array of arguments into another term.
  • Binary - Encapsulate binary data within a query.
  • Do - Call an anonymous function using return values from other ReQL commands or queries as arguments.
  • Branch - Evaluate one of two control paths based on the value of an expression.
  • ForEach - Loop over a sequence, evaluating the given write query for each element.
  • Range - Generate a stream of sequential integers in a specified range.
  • Error - Throw a runtime error.
  • Default - Handle non-existence errors.
  • Expr - Construct a ReQL JSON value from a native type.
  • JS - Create a javascript expression.
  • CoerceTo - Convert a value of one type into another.
  • TypeOf - Gets the type of a value.
  • Info - Get information about a ReQL value.
  • JSON - Parse a JSON string on the server.
  • ToJSON - Convert a ReQL value or object to a JSON string.
  • HTTP - Retrieve data from the specified URL over HTTP.
  • UUID - Return a UUID (universally unique identifier), a string that can be used as a unique ID.

Geospatial commands

  • Circle - Construct a circular line or polygon.
  • Distance - Compute the distance between a point and another geometry object.
  • Fill - Convert a Line object into a Polygon object.
  • GeoJSON - Convert a GeoJSON object to a ReQL geometry object.
  • ToGeoJSON - Convert a ReQL geometry object to a GeoJSON object.
  • GetIntersecting - Get all documents where the given geometry object intersects the geometry object of the requested geospatial index.
  • GetNearest - Get all documents where the specified geospatial index is within a certain distance of the specified point (default 100 kilometers).
  • Includes - Tests whether a geometry object is completely contained within another.
  • Intersects - Tests whether two geometry objects intersect with one another.
  • Line - Construct a geometry object of type Line.
  • Point - Construct a geometry object of type Point.
  • Polygon - Construct a geometry object of type Polygon.
  • PolygonSub - Use polygon2 to “punch out” a hole in polygon1.