Query

This module contains functions that generate query objects, suitable to be passed into FaunaClient.query.

In addition to these functions, queries may contain:

  • None
  • Numbers (1, 2.5)
  • Strings ("foo")
  • Lists ([1, "foo"])
  • Dicts ({"foo": "bar"})
  • A Ref, SetRef, FaunaTime, or datetime.date.

For example: select("a", {"a": Ref("123", Ref("widgets", Native.CLASSES))}).

faunadb.query.abort(msg)

See the docs.

faunadb.query.add(*numbers)

See the docs.

faunadb.query.all(collection)

See the docs.

faunadb.query.and_(*booleans)

See the docs.

faunadb.query.and_expr(*args, **kvargs)

See the docs.

faunadb.query.any(collection)

See the docs.

faunadb.query.append(elements, collection)

See the docs.

faunadb.query.at(timestamp, expr)

See the docs.

faunadb.query.call(ref_, *arguments)

See the docs.

faunadb.query.casefold(string, normalizer=None)

See the docs.

faunadb.query.class_(*args, **kvargs)

See the docs.

faunadb.query.class_expr(*args, **kvargs)

See the docs.

faunadb.query.classes(*args, **kvargs)

See the docs.

faunadb.query.collection(collection_name, scope=None)

See the docs.

faunadb.query.collections(scope=None)

See the docs.

faunadb.query.concat(strings, separator=None)

See the docs.

faunadb.query.contains(path, in_)

See the docs.

faunadb.query.contains_str(value, search)

See the docs.

faunadb.query.contains_str_regex(value, pattern)

See the docs.

faunadb.query.count(collection)

See the docs.

faunadb.query.create(collection_ref, params)

See the docs.

faunadb.query.create_class(*args, **kvargs)

See the docs.

faunadb.query.create_collection(collection_params)

See the docs.

faunadb.query.create_database(db_params)

See the docs.

faunadb.query.create_function(func_params)

See the docs.

faunadb.query.create_index(index_params)

See the docs.

faunadb.query.create_key(key_params)

See the docs.

faunadb.query.create_role(func_params)

See the docs.

faunadb.query.credentials(scope=None)

See the docs.

faunadb.query.database(db_name, scope=None)

See the docs.

faunadb.query.databases(scope=None)

See the docs.

faunadb.query.date(string)

See the docs.

faunadb.query.day_of_month(expr)

See the docs.

faunadb.query.day_of_week(expr)

See the docs.

faunadb.query.day_of_year(expr)

See the docs.

faunadb.query.delete(ref_)

See the docs.

faunadb.query.difference(*sets)

See the docs.

faunadb.query.distinct(set)

See the docs.

faunadb.query.divide(*numbers)

See the docs.

faunadb.query.do(*expressions)

See the docs.

faunadb.query.documents(collections)

See the docs.

faunadb.query.drop(number, collection)

See the docs.

faunadb.query.ends_with(value, search)

See the docs.

faunadb.query.epoch(number, unit)

See the docs.

faunadb.query.equals(*values)

See the docs.

faunadb.query.events(ref_set)

See the docs.

faunadb.query.exists(ref_, ts=None)

See the docs.

faunadb.query.filter_(expr, collection)

See the docs.

faunadb.query.filter_expr(*args, **kvargs)

See the docs.

faunadb.query.find_str(value, find, start=None)

See the docs.

faunadb.query.find_str_regex(value, pattern, start=None, numResults=None)

See the docs.

faunadb.query.foreach(expr, collection)

See the docs.

faunadb.query.format(string, *values)

See the docs.

faunadb.query.function(fn_name, scope=None)

See the docs.

faunadb.query.functions(scope=None)

See the docs.

faunadb.query.get(ref_, ts=None)

See the docs.

faunadb.query.gt(*values)

See the docs.

faunadb.query.gte(*values)

See the docs.

faunadb.query.has_identity()

See the docs.

faunadb.query.hour(expr)

See the docs.

faunadb.query.identify(ref_, password)

See the docs.

faunadb.query.identity()

See the docs.

faunadb.query.if_(condition, then, else_)

See the docs.

faunadb.query.if_expr(*args, **kvargs)

See the docs.

faunadb.query.index(index_name, scope=None)

See the docs.

faunadb.query.indexes(scope=None)

See the docs.

faunadb.query.insert(ref_, ts, action, params)

See the docs.

faunadb.query.intersection(*sets)

See the docs.

faunadb.query.is_empty(collection)

See the docs.

faunadb.query.is_nonempty(collection)

See the docs.

faunadb.query.join(source, target)

See the docs.

faunadb.query.key_from_secret(secret)

See the docs.

faunadb.query.keys(scope=None)

See the docs.

faunadb.query.lambda_(var_name_or_pattern, expr)

See the docs.

faunadb.query.lambda_expr(*args, **kvargs)

See the docs.

faunadb.query.lambda_query(func)

See the docs. This form generates var objects for you, and is called like:

query.lambda_query(lambda a: query.add(a, a))
# Produces: {
#  "lambda": "a",
#  "expr": {"add": ({"var": "a"}, {"var": "a"})}
# }

You usually don’t need to call this directly as lambdas in queries will be converted for you. For example: query.map_(lambda a: query.add(a, 1), collection).

You can also use lambda_ directly.

Parameters:func – Takes one or more var expressions and uses them to construct an expression. If this has more than one argument, the lambda destructures an array argument. (To destructure single-element arrays use lambda_.)
faunadb.query.length(value)

See the docs.

faunadb.query.let(*args, **kwargs)

See the docs.

faunadb.query.login(ref_, params)

See the docs.

faunadb.query.logout(delete_tokens)

See the docs.

faunadb.query.lowercase(value)

See the docs.

faunadb.query.lt(*values)

See the docs.

faunadb.query.lte(*values)

See the docs.

faunadb.query.ltrim(value)

See the docs.

faunadb.query.map_(expr, collection)

See the docs.

faunadb.query.map_expr(*args, **kvargs)

See the docs.

faunadb.query.match(index, *terms)

See the docs.

faunadb.query.mean(collection)

See the docs.

faunadb.query.merge(merge, with_, lambda_=None)

See the docs.

faunadb.query.minute(expr)

See the docs.

faunadb.query.modulo(*numbers)

See the docs.

faunadb.query.month(expr)

See the docs.

faunadb.query.move_database(from_, to)

See the docs.

faunadb.query.multiply(*numbers)

See the docs.

faunadb.query.new_id()

See the docs.

faunadb.query.next_id(*args, **kvargs)

See the docs.

faunadb.query.ngram(terms, min=None, max=None)

See the docs.

faunadb.query.not_(boolean)

See the docs.

faunadb.query.not_expr(*args, **kvargs)

See the docs.

faunadb.query.now()

See the docs.

faunadb.query.or_(*booleans)

See the docs.

faunadb.query.or_expr(*args, **kvargs)

See the docs.

faunadb.query.paginate(set, size=None, ts=None, after=None, before=None, events=None, sources=None)

See the docs. You may want to convert the result of this to a Page.

faunadb.query.prepend(elements, collection)

See the docs.

faunadb.query.query(_lambda)

See the docs.

faunadb.query.range(set, from_, to)

See the docs.

faunadb.query.reduce(lambda_, initial, collection)

See the docs.

faunadb.query.ref(collection_ref, id=None)

See the docs.

faunadb.query.regex_escape(value)

See the docs.

faunadb.query.remove(ref_, ts, action)

See the docs.

faunadb.query.repeat(value, number=None)

See the docs.

faunadb.query.replace(ref_, params)

See the docs.

faunadb.query.replace_str(value, find, replace)

See the docs.

faunadb.query.replace_str_regex(value, pattern, replace, first=None)

See the docs.

faunadb.query.role(role_name, scope=None)

See the docs.

faunadb.query.roles(scope=None)

See the docs.

faunadb.query.rtrim(value)

See the docs.

faunadb.query.second(expr)

See the docs.

faunadb.query.select(path, from_)

See the docs. See also select_with_default().

faunadb.query.select_all(path, from_)

See the docs.

faunadb.query.select_with_default(path, from_, default)

See the docs.

faunadb.query.singleton(ref_)

See the docs.

faunadb.query.space(count)

See the docs.

faunadb.query.starts_with(value, search)

See the docs.

faunadb.query.substring(value, start, length=None)

See the docs.

faunadb.query.subtract(*numbers)

See the docs.

faunadb.query.sum(collection)

See the docs.

faunadb.query.take(number, collection)

See the docs.

faunadb.query.time(string)

See the docs.

faunadb.query.time_add(base, offset, unit)

See the docs.

faunadb.query.time_diff(start, finish, unit)

See the docs.

faunadb.query.time_subtract(base, offset, unit)

See the docs.

faunadb.query.titlecase(value)

See the docs.

faunadb.query.to_date(expr)

See the docs.

faunadb.query.to_micros(expr)

See the docs.

faunadb.query.to_millis(expr)

See the docs.

faunadb.query.to_number(expr)

See the docs.

faunadb.query.to_seconds(expr)

See the docs.

faunadb.query.to_time(expr)

See the docs.

faunadb.query.tokens(scope=None)

See the docs.

faunadb.query.trim(value)

See the docs.

faunadb.query.union(*sets)

See the docs.

faunadb.query.update(ref_, params)

See the docs.

faunadb.query.uppercase(value)

See the docs.

faunadb.query.var(var_name)

See the docs.

faunadb.query.year(expr)

See the docs.