CrossClj

0.10.1 docs

SourceDocs



RECENT
    VARS
    add
    all
    and
    any
    append
    asc
    avg
    between
    branch
    change-at
    changes
    circle
    close
    coerce-to
    concat-map
    config
    connect
    contains
    count
    date
    day
    day-of-week
    day-of-year
    db
    db-create
    db-drop
    db-list
    delete
    delete-at
    desc
    difference
    distance
    distinct
    div
    do
    downcase
    during
    epoch-time
    eq
    eq-join
    error
    fill
    filter
    fn
    for-each
    ge
    geojson
    get
    get-all
    get-field
    get-intersection
    get-nearest
    group
    gt
    has-fields
    hours
    http
    in-timezone
    includes
    index-create
    index-drop
    index-list
    index-rename
    index-status
    index-wait
    indexes-of
    info
    inner-join
    insert
    insert-at
    intersects
    is-empty
    iso8601
    json
    keys
    le
    limit
    line
    literal
    lt
    make-array
    map
    match
    max
    maxval
    merge
    min
    minutes
    minval
    mod
    month
    mul
    ne
    not
    now
    nth
    object
    or
    order-by
    outer-join
    pluck
    point
    polygon
    polygon-sub
    prepend
    random
    rebalance
    reduce
    replace
    replace-vars
    run
    sample
    seconds
    set-difference
    set-insert
    set-intersection
    set-union
    skip
    slice
    splice-at
    split
    status
    sub
    sum
    sync
    table
    table-create
    table-drop
    table-list
    time
    time-of-day
    timezone
    to-epoch-time
    to-geojson
    to-iso8601
    type-of
    ungroup
    union
    upcase
    update
    uuid
    with-fields
    without
    year
    zip

    « Index of all namespaces of this project

    Public interface to clj-rethinkdb. You should only need to require this namespace.
    
    Priority of databases used in queries:
    1. If a database is explicitly specified as part of a query it will always be used.
    2. If there is no database used in the query AND a database is set on the database
       at connection time (with the :db parameter), then this will be used.
    3. If there is no database in the query or connection, then RethinkDB will fall back
       to using the "test" database (You probably don't want this).
    
    N.B. Database names are validated at query time, not connection time.
    (add & args)
    Sum numbers, concatenate strings or concatenate arrays.
    
    (and & bools)
    Compute the logical "and" of two or more values.
    
    (append sq x)
    Append a value to an array.
    
    (asc field-name)
    Specify ascending order.
    
    (avg sq)(avg sq field-or-func)
    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 ``nil`` or a non-existence
    error.
    (between sel lower-key upper-key & [optargs])
    Get all documents between two keys. Accepts three optional arguments: ``index``,
    ``left-bound``, and ``right-bound``. If ``index`` is set to the name of a secondary
    index, ``between`` will return all documents where that index's value is in the
    specified range (it uses the primary key by default). ``left-bound`` or
    ``right-bound`` may be set to open or closed to indicate whether or not to
    include that endpoint of the range (by default, ``left-bound`` is closed and
    ``right-bound`` is open).
    (branch bool true-branch false-branch)
    If the ``bool`` expression returns ``false`` or ``nil``, the ``false-branch`` will be
    evaluated. Otherwise, the ``true-branch`` will be evaluated.
    (change-at sq n x)
    Change a value in an array at a given index. Returns the modified array.
    
    (changes table)
    Return an infinite stream of objects representing changes to a table or a
    document.
    (circle point radius & [optargs])
    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).
    (close cursor)
    (coerce-to x s)
    Convert a value of one type into another.
    
    (concat-map sel func)
    Concatenate one or more elements into a single sequence using a mapping
    function.
    (config table-or-db)
    Query (read and/or update) the configurations for individual tables or
    databases.
    Creates a database connection to a RethinkDB host
    [& {:keys [host port token auth-key db]
         :or {host "127.0.0.1"
              port 28015
              token 0
              auth-key ""
              db nil}}
    (contains sq x-or-func)
    Returns whether or not a sequence contains all the specified values, or if
    functions are provided instead, returns whether or not a sequence contains
    values matching all the specified functions.
    (count sq)(count sq x-or-func)
    Count the number of elements in the sequence. With a single argument, count
    the number of elements equal to it. If the argument is a function, it is
    equivalent to calling filter before count.
    (date time-obj)
    Return a new time object only based on the day, month and year (i.e. the same
    day at 00:00).
    (day time-obj)
    Return the day of a time object as a number between 1 and 31.
    
    (day-of-week time-obj)
    Return the day of week of a time object as a number between 1 and 7
    (following ISO 8601 standard). 
    (day-of-year time-obj)
    Return the day of the year of a time object as a number between 1 and 366
    (following ISO 8601 standard).
    (db db-name)
    Reference a database.
    
    (db-create db-name)
    Creates a database.
    
    (db-drop db-name)
    Drops a database.
    
    (db-list)
    List all database names in the system.
    
    (delete obj-or-sq & [optargs])
    Delete one or more documents from a table.
    
    (delete-at sq idx)(delete-at sq idx end-idx)
    Remove one or more elements from an array at a given index. Returns the
    modified array.
    (desc field-name)
    Specify descending order.
    
    (difference sq1 sq2)
    Remove the elements of one array from another array.
    
    (distance point1 point2 & [optargs])
    Compute the distance between a point and another geometry object. At least
    one of the geometry objects specified must be a point.
    (distinct sq)
    Remove duplicate elements from the sequence.
    
    (div & args)
    Divide numbers.
    
    (do args fun)
    Evaluate an expression and pass its values as arguments to a function or to
    an expression.
    (downcase s)
    Lowercases a string.
    
    (during time-obj start-time end-time & [optargs])
    Return if a time is between two other times (by default, inclusive for the
    start, exclusive for the end).
    (epoch-time i)
    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).
    (eq & args)
    Test if values are equal.
    
    (eq-join sq index-name table & [optargs])
    Join tables using a field on the left-hand sequence matching primary keys or
    secondary indexes on the right-hand table. ``eq-join`` is more efficient than
    other ReQL join types, and operates much faster. Documents in the result set
    consist of pairs of left-hand and right-hand documents, matched when the
    field on the left-hand side exists and is non-null and an entry with that
    field's value exists in the specified index on the right-hand side.
    (error)(error s)
    Throw a runtime error.
    
    (fill point)
    Convert a Line object into a Polygon object. If the last point does not
    specify the same coordinates as the first point, ``fill`` will close the
    polygon by connecting them.
    (filter sq obj-or-func & [optargs])
    Get all the documents for which the given predicate is true.
    
    Filter can be called on a sequence, selection, or a field containing an array
    of elements. The return type is the same as the type on which the function
    was called on.
    
    Passing a ``:default`` optional argument can change the handling of
    documents with missing fields.
    
    - `{:default true}` will return documents with missing fields,
      rather than ignore them.
    - `{:default (r/error))` will cause any non-existence error to
      raise an exception.
    - `{:default false}` (the default) will ignore documents where
      a specified field is missing.
    macro
    (fn args & [body])
    (for-each sq func)
    Loop over a sequence, evaluating the given write query for each element.
    
    (ge & args)
    Test if every value is greater than or equal to the following
    
    (geojson obj)
    Convert a GeoJSON object to a ReQL geometry object.
    
    (get table id)
    Get a document by primary key.
    
    If no document exists with that primary key, get will return ``nil``
    (get-all table ids & [optargs])
    Get all documents where the given value matches the value of the requested
    index.
    (get-field sel field-name)
    Get a single field from an object.
    
    (get-intersection table geo & [optargs])
    Get all documents where the given geometry object intersects the geometry
    object of the requested geospatial index.
    (get-nearest table geo & [optargs])
    Get all documents where the specified geospatial index is within a certain
    distance of the specified point (default 100 kilometers).
    (group sq s)
    Takes a stream and partitions it into multiple groups based on the fields or
    functions provided. Commands chained after ``group`` will be called on each of
    these grouped sub-streams, producing grouped data.
    (gt & args)
    Test if every value is greater than the following.
    
    (has-fields obj-or-sq x)
    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.
    (hours time-obj)
    Return the hour in a time object as a number between 0 and 23.
    
    (http url & [optargs])
    Retrieve data from the specified URL over HTTP. The return type depends on
    the ``result-format`` option, which checks the Content-Type of the response by
    default.
    (in-timezone time-obj s)
    Return a new time object with a different timezone. While the time stays the
    same, the results returned by functions such as ``hours`` will change since they
    take the timezone into account. The timezone argument has to be of the ISO
    8601 format.
    (includes geo1 geo2)
    Tests whether a geometry object is completely contained within another. When
    applied to a sequence of geometry objects, ``includes`` acts as a filter,
    returning a sequence of objects from the sequence that include the argument.
    (index-create table index-name func & [optargs])
    Create a new secondary index on a table.
    
    (index-drop table index-name)
    Delete a previously created secondary index.
    
    (index-list table)
    List all the secondary indexes of a table.
    
    (index-rename table old-name new-name & [optargs])
    Rename an existing secondary index on a table. If the optional argument
    ``overwrite`` is specified as ``true``, a previously existing index with the new name
    will be deleted and the index will be renamed. If ``overwrite`` is ``false`` (the
    default) an error will be raised if the new index name already exists.
    (index-status table & index-names)
    Get the status of the specified indexes on this table, or the status of all
    indexes on this table if no indexes are specified.
    (index-wait table & index-names)
    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.
    (indexes-of sq obj-or-func)
    Get the indexes of an element in a sequence. If the argument is a predicate,
    get the indexes of all elements matching it.
    (info x)
    Get information about a ReQL value.
    
    (inner-join sq1 sq2 func)
    Returns an inner join of two sequences.
    
    (insert table objs & [optargs])
    Insert documents into a table. Accepts a list of documents.
    
    (insert-at sq n x)
    Insert a value in to an array at a given index. Returns the modified array.
    
    (intersects geo1 geo2)
    Tests whether two geometry objects ``intersect`` with one another. When applied
    to a sequence of geometry objects, intersects acts as a filter, returning a
    sequence of objects from the sequence that intersect with the argument.
    (is-empty sq)
    Test if a sequence is empty.
    
    (iso8601 s & [optargs])
    Create a time object based on an ISO 8601 date-time string (e.g.
    '2013-01-01T01:01:01+00:00'). We support all valid ISO 8601 formats except
    for week dates. If you pass an ISO 8601 date-time without a time zone, you must
    specify the time zone with the ``default-timezone`` argument.
    (json s)
    Parse a JSON string on the server.
    
    (keys obj)
    Return an array containing all of the object's keys.
    
    (le & args)
    Test if every value is less than or equal to the following
    
    (limit sq n)
    End the sequence after the given number of elements.
    
    (line points)
    Construct a geometry object of type Line. The line can be specified in one
    of two ways:
    
    - Two or more two-item arrays, specifying longitude and latitude numbers of
      the line's vertices;
    - Two or more Point objects specifying the line's vertices.
    (literal x)
    Replace an object in a field instead of merging it with an existing object
    in a merge or update operation.
    (lt & args)
    Test if every value is less than the following
    
    (make-array & xs)
    (map sq obj-or-func)
    Transform each element of one or more sequences by applying a mapping
    function to them. If ``map`` is run with two or more sequences, it will iterate
    for as many items as there are in the shortest sequence.
    (match s regex-str)
    Matches against a regular expression. If there is a match, returns an object
    with the fields:
    
    - ``str``: The matched string
    - ``start``: The matched string's start
    - ``end``: The matched string's end
    - ``groups``: The capture groups defined with parentheses
    
    If no match is found, returns ``nil``.
    (max sq)(max sq field-or-func)
    Finds the maximum element of a sequence.
    
    (merge obj-or-sq1 obj-or-sq2)
    Merge two objects together to construct a new object with properties from
    both. Gives preference to attributes from the second object when there is a
    conflict.
    (min sq)(min sq field-or-func)
    Finds the minimum element of a sequence.
    
    (minutes time-obj)
    Return the minute in a time object as a number between 0 and 59.
    
    (mod & args)
    Find the remainder when dividing numbers.
    
    (month time-obj)
    Return the month of a time object as a number between 1 and 12.
    
    (mul & args)
    Multiply numbers, or make a periodic array.
    
    (ne & args)
    Test if values are not equal.
    
    (not bool)
    Compute the logical inverse (not) of an expression.
    
    (now)
    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
    ``now`` will always return the same time inside a query.
    (nth sq n)
    Get the *nth* element of a sequence.
    
    (object & key-vals)
    Creates an object from a list of key-value pairs.
    
    (or & bools)
    Compute the logical "or" of two or more values.
    
    (order-by sel field-or-ordering)
    Sort the sequence by document values of the given key(s). To specify the
    ordering, wrap the attribute with either ``r.asc`` or ``r.desc`` (defaults to
    ascending).
    
    Sorting without an index requires the server to hold the sequence in memory,
    and is limited to 100,000 documents (or the setting of the ``array-limit`` option
    for run). Sorting with an index can be done on arbitrarily large tables, or
    after a between command using the same index.
    (outer-join sq1 sq2 func)
    Returns a left outer join of two sequences.
    
    (pluck obj-or-sq x)
    Plucks out one or more attributes from either an object or a sequence of
    objects (projection).
    (point x y & [optargs])
    Construct a geometry object of type Point. The point is specified by two
    floating point numbers, the longitude (−180 to 180) and the latitude (−90 to
    90) of the point on a perfect sphere.
    (polygon points)
    Construct a geometry object of type Polygon. The Polygon can be specified in
    one of two ways:
    
    - Three or more two-item arrays, specifying longitude and latitude numbers of the
      polygon's vertices;
    - Three or more Point objects specifying the polygon's vertices.
    (polygon-sub outer-polygon inner-polygon)
    Use ``inner-polygon`` to "punch out" a hole in ``outer-polygon``. ``inner-polygon``
    must be completely contained within ``outer-polygon`` and must have no holes
    itself (it must not be the output of ``polygon-sub`` itself).
    (prepend sq x)
    Prepend a value to an array.
    
    (random n1 n2 & [optargs])
    Generate a random number between given bounds.
    
    (rebalance table-or-db)
    Rebalances the shards of a table. When called on a database, all the tables
    in that database will be rebalanced.
    (reduce sq func)
    Produce a single value from a sequence through repeated application of a
    reduction function.
    (replace sel obj-or-func & [optargs])
    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.
    (replace-vars query)
    (run query conn)
    (sample sq n)
    Select a given number of elements from a sequence with uniform random
    distribution. Selection is done without replacement.
    (seconds time-obj)
    Return the seconds in a time object as a number between 0 and 59.999 (double
    precision).
    (set-difference sq1 sq2)
    Remove the elements of one array from another and return them as a set (an
    array with distinct values).
    (set-insert sq x)
    Add a value to an array and return it as a set (an array with distinct values).
    
    (set-intersection sq1 sq2)
    Intersect two arrays returning values that occur in both of them as a set
    (an array with distinct values).
    (set-union sq1 sq2)
    Add a several values to an array and return it as a set (an array with
    distinct values).
    (skip sel n)
    Skip a number of elements from the head of the sequence.
    
    (slice sq n1 n2)
    Return the elements of a sequence within the specified range.
    
    (splice-at sq1 n sq2)
    Insert several values in to an array at a given index. Returns the modified
    array.
    (split s)(split s separator)(split s separator max-splits)
    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 ``max-splits`` times. (Can be called with ``nil`` as the separator
    if you want to split on whitespace while still specifying ``max-splits``.)
    (status table)
    Return the status of a table.
    
    (sub & args)
    Subtract numbers.
    
    (sum sq)(sum sq field-or-func)
    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 ``nil`` or a non-existence error.
    (sync table)
    ``sync`` ensures that writes on a given table are written to permanent storage.
    Queries that specify soft durability `({:durability "soft"})` do not give such
    guarantees, so ``sync`` can be used to ensure the state of these queries. A call
    to ``sync`` does not return until all previous writes to the table are
    persisted.
    (table table-name)(table db table-name)
    Select all documents in a table. This command can be chained with other
    commands to do further processing on the data. If no db is provided then precedence
    follows the order given in the rethinkdb.query ns documentation.
    (table-create db table-name & [optargs])
    Create a table.
    
    (table-drop table-name)(table-drop db table-name)
    Drop a table. If no db is provided then precedence follows the
    order given in the rethinkdb.query ns documentation.
    (table-list)(table-list db)
    List all table names in a database. If no db is provided then precedence
    follows the order given in the rethinkdb.query ns documentation.
    (time & date-time-parts)
    Create a time object for a specific time.
    
    (time-of-day time-obj)
    Return the number of seconds elapsed since the beginning of the day stored
    in the time object.
    (timezone time-obj)
    Return the timezone of the time object.
    
    (to-epoch-time time-obj)
    Convert a time object to its epoch time.
    
    (to-geojson geo)
    Convert a ReQL geometry object to a GeoJSON object.
    
    (to-iso8601 time-obj)
    Convert a time object to its ISO 8601 format.
    
    (type-of x)
    Gets the type of a value.
    
    (ungroup grouped)
    Takes a grouped stream or grouped data and turns it into an array of objects
    representing the groups. Any commands chained after ``ungroup`` will operate on
    this array, rather than operating on each group individually. This is useful
    if you want to e.g. order the groups by the value of their reduction.
    (union & sqs)
    Concatenate two sequences.
    
    (upcase s)
    Uppercases a string.
    
    (update sel obj-or-func & [optargs])
    Update JSON documents in a table. Accepts a JSON document, a ReQL
    expression, or a combination of the two.
    (uuid)
    Return a UUID (universally unique identifier), a string that can be used as
    a unique ID.
    (with-fields sq fields)
    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 ``has-fields`` followed by ``pluck`` on a sequence.
    (without obj-or-sq fields)
    The opposite of pluck; takes an object or a sequence of objects, and returns
    them with the specified paths removed.
    (year time-obj)
    Return the year of a time object.
    
    (zip sq)
    Used to 'zip' up the result of a join by merging the 'right' fields into 'left' fields of each member of the sequence.