Generic Functions and Operators
Compare two values for equality. | |
Compare two values for inequality. | |
Compare two (potentially empty) values for equality. | |
Compare two (potentially empty) values for inequality. | |
Less than operator. | |
Greater than operator. | |
Less or equal operator. | |
Greater or equal operator. | |
A polymorphic function to calculate a “length” of its first argument. | |
A polymorphic function to test if the haystack contains the needle. | |
A polymorphic function to find index of an element in a sequence. |
operator
anytype = anytype
anytype = anytype -> bool
Compare two values for equality.
db>
select 3 = 3.0;
{true}
db>
select 3 = 3.14;
{false}
db>
select [1, 2] = [1, 2];
{true}
db>
select (1, 2) = (x := 1, y := 2);
{true}
db>
select (x := 1, y := 2) = (a := 1, b := 2);
{true}
db>
select 'hello' = 'world';
{false}
operator
anytype != anytype
anytype != anytype -> bool
Compare two values for inequality.
db>
select 3 != 3.0;
{false}
db>
select 3 != 3.14;
{true}
db>
select [1, 2] != [2, 1];
{false}
db>
select (1, 2) != (x := 1, y := 2);
{false}
db>
select (x := 1, y := 2) != (a := 1, b := 2);
{false}
db>
select 'hello' != 'world';
{true}
operator
anytype ?= anytype
optional anytype ?= optional anytype -> bool
Compare two (potentially empty) values for equality.
Works the same as regular \=, but also allows comparing {}
. Two {}
are considered equal.
db>
select {1} ?= {1.0};
{true}
db>
select {1} ?= <int64>{};
{false}
db>
select <int64>{} ?= <int64>{};
{true}
operator
anytype ?!= anytype
optional anytype ?!= optional anytype -> bool
Compare two (potentially empty) values for inequality.
Works the same as regular !=, but also allows comparing {}
. Two {}
are considered equal.
db>
select {2} ?!= {2};
{false}
db>
select {1} ?!= <int64>{};
{true}
db>
select <bool>{} ?!= <bool>{};
{false}
operator
anytype < anytype
anytype < anytype -> bool
Less than operator.
Return true
if the value of the left expression is less than the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:
db>
select 1 < 2;
{true}
db>
select 2 < 2;
{false}
db>
select 'hello' < 'world';
{true}
db>
select (1, 'hello') < (1, 'world');
{true}
operator
anytype > anytype
anytype > anytype -> bool
Greater than operator.
Return true
if the value of the left expression is greater than the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:
db>
select 1 > 2;
{false}
db>
select 3 > 2;
{true}
db>
select 'hello' > 'world';
{false}
db>
select (1, 'hello') > (1, 'world');
{false}
operator
anytype <= anytype
anytype <= anytype -> bool
Less or equal operator.
Return true
if the value of the left expression is less than or equal to the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:
db>
select 1 <= 2;
{true}
db>
select 2 <= 2;
{true}
db>
select 3 <= 2;
{false}
db>
select 'hello' <= 'world';
{true}
db>
select (1, 'hello') <= (1, 'world');
{true}
operator
anytype >= anytype
anytype >= anytype -> bool
Greater or equal operator.
Return true
if the value of the left expression is greater than or equal to the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:
db>
select 1 >= 2;
{false}
db>
select 2 >= 2;
{true}
db>
select 3 >= 2;
{true}
db>
select 'hello' >= 'world';
{false}
db>
select (1, 'hello') >= (1, 'world');
{false}
function
len()
std::len(value: str) -> int64std::len(value: bytes) -> int64std::len(value: array<anytype>) -> int64
A polymorphic function to calculate a “length” of its first argument.
Return the number of characters in a str, or the number of bytes in bytes, or the number of elements in an array.
db>
select len('foo');
{3}
db>
select len(b'bar');
{3}
db>
select len([2, 5, 7]);
{3}
function
contains()
std::contains(haystack: str, needle: str) -> boolstd::contains(haystack: bytes, needle: bytes) -> boolstd::contains(haystack: array<anytype>, needle: anytype) -> boolstd::contains(haystack: range<anypoint>, needle: range<anypoint>) -> std::boolstd::contains(haystack: range<anypoint>, needle: anypoint) -> std::bool
A polymorphic function to test if the haystack contains the needle.
When the haystack is str or bytes, return true
if needle is contained as a subsequence in it and false
otherwise.
db>
select contains('qwerty', 'we');
{true}
db>
select contains(b'qwerty', b'42');
{false}
When the haystack is an array, return true
if the array contains the specified element and false
otherwise.
db>
select contains([2, 5, 7, 2, 100], 2);
{true}
When the haystack is a range, return true
if it contains either the specified sub-range or element and false
otherwise.
db>
select contains(range(1, 10), range(2,5));
{true}
db>
select contains(range(1, 10), range(2,15));
{false}
db>
select contains(range(1, 10), 2);
{true}
db>
select contains(range(1, 10), 10);
{false}
function
find()
std::find(haystack: str, needle: str) -> int64std::find(haystack: bytes, needle: bytes) -> int64std::find(haystack: array<anytype>, needle: anytype, from_pos: int64=0) -> int64
A polymorphic function to find index of an element in a sequence.
When the haystack is str or bytes, return the index of the first occurrence of needle in it.
When the haystack is an array, return the index of the first occurrence of the specific needle element. For array inputs it is also possible to provide an optional from_pos argument to specify the position from which to start the search.
If the needle is not found, return -1
.
db>
select find('qwerty', 'we');
{1}
db>
select find(b'qwerty', b'42');
{-1}
db>
select find([2, 5, 7, 2, 100], 2);
{0}
db>
select find([2, 5, 7, 2, 100], 2, 1);
{3}