|
The boolean data type can only store true or false values. These can
be directly compared for equality or inequality. They can also be
compared to the Boolean literal values of true and false .
|
|
Null is a special marker used to indicate that a data value does not
exist. It is a representation of missing information, indicating a lack
of a value. A lack of a value is not the same thing as a value of zero,
in the same way that a lack of an answer is not the same thing as an
answer of "no".
Null is a value that can be directly compared for application programmer
simplicity.
This means that Null == Null returns true .
|
|
Numbers are any real number which are bounded by the double precision
range (64-bit), such as 3, -27, 3.1415. Neither infinity nor NaN
are allowed.
Functions that operate on numbers:
Abs
|
Returns the absolute value of a number.
|
Acos
|
Returns the arc cosine of a number.
|
Add
|
Returns the sum of one or more numbers.
|
Asin
|
Returns the arc sine of a number.
|
Atan
|
Returns the arc tangent of a number.
|
BitAnd
|
Returns the bitwise AND of one or more numbers.
|
BitNot
|
Returns the bitwise AND of one or more numbers.
|
BitOr
|
Returns the bitwise OR of one or more numbers.
|
BitXor
|
Returns the bitwise exclusive-OR of one or more numbers.
|
Ceil
|
Returns an integer that is greater than, or equal to, a number.
|
Cos
|
Returns the cosine of a number.
|
Cosh
|
Returns the hyperbolic cosine of a number.
|
Count
|
Counts the items in an array or set.
|
Degrees
|
Converts a number from radians to degrees.
|
Divide
|
Returns the quotient of two or more numbers.
|
Exp
|
Returns e raised to the power of a number.
|
Floor
|
Returns an integer that is less than, or equal to, a number.
|
Hypot
|
Returns the length of a hypotenuse of a right triangle, given the
lengths of the other two sides.
|
Ln
|
Returns the natural logarithm (base e) of a number.
|
Log
|
Returns the natural logarithm (base 10) of a number.
|
Max
|
Returns the largest value in a list of numbers.
|
Mean
|
Returns the average value of the items in an array or set.
|
Min
|
Returns the smallest value in a list of numbers.
|
Modulo
|
Returns the remainder after dividing a list of numbers.
|
Multiply
|
Returns the product of a list of numbers.
|
Pow
|
Returns the value of a number raised to an exponent.
|
Radians
|
Converts a number from degrees to radians.
|
Round
|
Returns the integer that is closest to a number.
|
Sign
|
Returns 1, 0, or -1 to indicate the sign of a number.
|
Sin
|
Returns the sine of a number.
|
Sinh
|
Returns the hyperbolic sine of a number.
|
Sqrt
|
Returns the square root of a number.
|
Subtract
|
Returns the difference of a list of numbers.
|
Sum
|
Sums the items in an array or set.
|
Tan
|
Returns the tangent of a number.
|
Tanh
|
Returns the hyperbolic tangent of a number.
|
Trunc
|
Truncates a number to the specified decimal places.
|
|
|
String data types store any letters, numbers, whitespaces, and/or
symbols in a fixed order.
FQL accepts and communicates strings as
UTF-8 encoded strings. For string
functions, any arguments or returned values which utilize offsets and
lengths operate using code
points.
Functions that operate on strings:
CaseFold
|
Converts a string into a case-normalized string.
|
Concat
|
Combines a list of strings into a single string.
|
ContainsStr
|
Tests whether a string contains a specific string.
|
ContainsStrRegex
|
Tests whether a string contains a specific pattern.
|
EndsWith
|
Tests whether a string ends with a specific string.
|
FindStr
|
Searches for a string within a string.
|
FindStrRegex
|
Searches for a regex pattern within a string.
|
Format
|
Formats arguments as a string according to a string of format specifiers.
|
LTrim
|
Removes all whitespace from the start of a string.
|
Length
|
Returns the length in codepoints of a string.
|
LowerCase
|
Converts a string to all lowercase.
|
RTrim
|
Removes all whitespace from the end of a string.
|
RegexEscape
|
Creates a regular expression that matches the input string verbatim.
|
Repeat
|
Creates a new string by repeating a string multiple times.
|
ReplaceStr
|
Replaces a portion of a string with another string.
|
ReplaceStrRegex
|
Replaces a pattern in a string with another string.
|
Space
|
Creates a whitespace string of the specified size.
|
StartsWith
|
Tests whether a string starts with a specific string.
|
SubString
|
Returns a portion of a string.
|
TitleCase
|
Converts a string to use TitleCase.
|
Trim
|
Removes all whitespace from the start and end of a string.
|
UpperCase
|
Converts a string to all uppercase.
|
|
|
A literal is a constant value for a given data type. Boolean,
Number, String, and Null all evaluate to their associated
type:
true, false // Boolean
1, 2 // Number
3.4, 1.2e10 // Number
"a", "b" // String
null // Null
|
|
An Array is a data structure that contains a group of elements.
When an Array is used in FQL, it evaluates to its contents.
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '[ 1, 2, { "concat": [ "Hen ", "Wen" ] } ]'
client.Query(Arr(1, 2, Concat(Arr("Hen ", "Wen"))));
System.out.println(client.query(
Arr(
Value(1),
Value(2),
Concat(Arr(Value("Hen "), Value("Wen")))
)).get());
result, _ := client.Query(f.Arr{1, 2, f.Concat(f.Arr{"Hen ", "Wen"})})
fmt.Println(result)
client.query(Arr(1, 2, Concat(Arr("Hen ", "Wen"))))
client.query([1, 2, q.concat(["Hen ", "Wen"])])
$client.query do
[1, 2, concat(['Hen ', 'Wen'])]
end
client.query(Arr(1, 2, Concat("Hen ", "Wen")))
client.query(
[1, 2, q.Concat(['Hen ', 'Wen'])]
)
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": [ 1, 2, "Hen Wen" ] }
Functions that operate on arrays:
All
|
Tests whether all of the provided values are true.
|
Any
|
Tests whether any of the provided values are true.
|
Append
|
Adds items to end of array.
|
Count
|
Counts the items in an array or set.
|
Difference
|
Returns an array of items in one array that are missing from additional
arrays.
|
Distinct
|
Returns an array of the distinct items within multiple arrays.
|
Drop
|
Removes items from start of array.
|
Filter
|
Fetches specific items from array.
|
Foreach
|
Iterates over array items.
|
Intersection
|
Returns an array of the items that exist in all arrays.
|
IsEmpty
|
Tests whether an array or set is empty.
|
IsNonEmpty
|
Tests whether an array or set contains items.
|
Map
|
Applies a function to all array items.
|
Max
|
Returns the largest value in a list of numbers.
|
Mean
|
Returns the average value of the items in an array or set.
|
Min
|
Returns the smallest value in a list of numbers.
|
Prepend
|
Adds items to start of array.
|
Reduce
|
Reduce an array or set to a result via a lambda function.
|
Sum
|
Sums the items in an array or set.
|
Take
|
Fetches items from start of array.
|
ToObject
|
Converts an array to an object.
|
Union
|
Returns an array that combines the items in multiple arrays.
|
|
|
The Object type represents a JSON-like object, where its values are a
collection of key/value pairs. The keys must be strings and the values
must be valid FQL data types. The value expressions are evaluated
sequentially in the order that they were specified, left to right.
Objects evaluate to their contents:
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{
"object": { "name": "Hen Wen", "age": { "add": [ 100, 10 ] } }
}'
client.Query(Obj("name", "Hen Wen", "age", Add(100, 10)));
System.out.println(
client.query(
Obj("name", Value("Hen Wen"), "age", Add(Value(100), Value(10)))
).get());
result, _ := client.Query(f.Obj{"name": "Hen Wen", "age": f.Add(100, 10)})
fmt.Println(result)
client.query(Obj("name" -> "Hen Wen", "age" -> Add(100, 10)))
client.query({"name": "Hen Wen", "age": q.add(100, 10)})
$client.query do
{ name: 'Hen Wen', age: add(100, 10) }
end
client.query(
Obj("name" => "Hen Wen", "age" => Add(100, 10))
)
client.query(
{ name: 'Hen Wen', age: q.Add(100, 10) }
)
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": { "name": "Hen Wen", "age": 110 } }
{ "name": "Hen Wen", "age": 110 }
{ name: "Hen Wen", age: 110 }
map[age:110 name:Hen Wen]
{ "name": "Hen Wen", "age": 110 }
{ "name": "Hen Wen", "age": 110 }
{ "name": "Hen Wen", "age": 110 }
{ "name": "Hen Wen", "age": 110 }
{ name: 'Hen Wen', age: 110 }
Functions that operate on objects:
Merge
|
Merge two objects into one, with an optional resolver lambda.
|
Select
|
Retrieves a specific field value from a document.
|
SelectAll
|
Retrieves all values for a specific field from a document.
|
ToArray
|
Converts an object to an array.
|
|