Generic Functions and Operators

anytype = anytype

Compare two values for equality.

anytype != anytype

Compare two values for inequality.

anytype ?= anytype

Compare two (potentially empty) values for equality.

anytype ?!= anytype

Compare two (potentially empty) values for inequality.

anytype < anytype

Less than operator.

anytype > anytype

Greater than operator.

anytype <= anytype

Less or equal operator.

anytype >= anytype

Greater or equal operator.

len()

A polymorphic function to calculate a “length” of its first argument.

contains()

A polymorphic function to test if the haystack contains the needle.

find()

A polymorphic function to find index of an element in a sequence.

operator

anytype = anytype

Generic - 图1

Generic - 图2

Generic - 图3

anytype = anytype -> bool

Compare two values for equality.

  1. db>
  1. select 3 = 3.0;
  1. {true}
  1. db>
  1. select 3 = 3.14;
  1. {false}
  1. db>
  1. select [1, 2] = [1, 2];
  1. {true}
  1. db>
  1. select (1, 2) = (x := 1, y := 2);
  1. {true}
  1. db>
  1. select (x := 1, y := 2) = (a := 1, b := 2);
  1. {true}
  1. db>
  1. select 'hello' = 'world';
  1. {false}

operator

anytype != anytype

Generic - 图4

Generic - 图5

Generic - 图6

anytype != anytype -> bool

Compare two values for inequality.

  1. db>
  1. select 3 != 3.0;
  1. {false}
  1. db>
  1. select 3 != 3.14;
  1. {true}
  1. db>
  1. select [1, 2] != [2, 1];
  1. {false}
  1. db>
  1. select (1, 2) != (x := 1, y := 2);
  1. {false}
  1. db>
  1. select (x := 1, y := 2) != (a := 1, b := 2);
  1. {false}
  1. db>
  1. select 'hello' != 'world';
  1. {true}

operator

anytype ?= anytype

Generic - 图7

Generic - 图8

Generic - 图9

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.

  1. db>
  1. select {1} ?= {1.0};
  1. {true}
  1. db>
  1. select {1} ?= <int64>{};
  1. {false}
  1. db>
  1. select <int64>{} ?= <int64>{};
  1. {true}

operator

anytype ?!= anytype

Generic - 图10

Generic - 图11

Generic - 图12

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.

  1. db>
  1. select {2} ?!= {2};
  1. {false}
  1. db>
  1. select {1} ?!= <int64>{};
  1. {true}
  1. db>
  1. select <bool>{} ?!= <bool>{};
  1. {false}

operator

anytype < anytype

Generic - 图13

Generic - 图14

Generic - 图15

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:

  1. db>
  1. select 1 < 2;
  1. {true}
  1. db>
  1. select 2 < 2;
  1. {false}
  1. db>
  1. select 'hello' < 'world';
  1. {true}
  1. db>
  1. select (1, 'hello') < (1, 'world');
  1. {true}

operator

anytype > anytype

Generic - 图16

Generic - 图17

Generic - 图18

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:

  1. db>
  1. select 1 > 2;
  1. {false}
  1. db>
  1. select 3 > 2;
  1. {true}
  1. db>
  1. select 'hello' > 'world';
  1. {false}
  1. db>
  1. select (1, 'hello') > (1, 'world');
  1. {false}

operator

anytype <= anytype

Generic - 图19

Generic - 图20

Generic - 图21

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:

  1. db>
  1. select 1 <= 2;
  1. {true}
  1. db>
  1. select 2 <= 2;
  1. {true}
  1. db>
  1. select 3 <= 2;
  1. {false}
  1. db>
  1. select 'hello' <= 'world';
  1. {true}
  1. db>
  1. select (1, 'hello') <= (1, 'world');
  1. {true}

operator

anytype >= anytype

Generic - 图22

Generic - 图23

Generic - 图24

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:

  1. db>
  1. select 1 >= 2;
  1. {false}
  1. db>
  1. select 2 >= 2;
  1. {true}
  1. db>
  1. select 3 >= 2;
  1. {true}
  1. db>
  1. select 'hello' >= 'world';
  1. {false}
  1. db>
  1. select (1, 'hello') >= (1, 'world');
  1. {false}

function

len()

Generic - 图25

Generic - 图26

Generic - 图27

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.

  1. db>
  1. select len('foo');
  1. {3}
  1. db>
  1. select len(b'bar');
  1. {3}
  1. db>
  1. select len([2, 5, 7]);
  1. {3}

function

contains()

Generic - 图28

Generic - 图29

Generic - 图30

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.

  1. db>
  1. select contains('qwerty', 'we');
  1. {true}
  1. db>
  1. select contains(b'qwerty', b'42');
  1. {false}

When the haystack is an array, return true if the array contains the specified element and false otherwise.

  1. db>
  1. select contains([2, 5, 7, 2, 100], 2);
  1. {true}

When the haystack is a range, return true if it contains either the specified sub-range or element and false otherwise.

  1. db>
  1. select contains(range(1, 10), range(2,5));
  1. {true}
  1. db>
  1. select contains(range(1, 10), range(2,15));
  1. {false}
  1. db>
  1. select contains(range(1, 10), 2);
  1. {true}
  1. db>
  1. select contains(range(1, 10), 10);
  1. {false}

function

find()

Generic - 图31

Generic - 图32

Generic - 图33

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.

  1. db>
  1. select find('qwerty', 'we');
  1. {1}
  1. db>
  1. select find(b'qwerty', b'42');
  1. {-1}
  1. db>
  1. select find([2, 5, 7, 2, 100], 2);
  1. {0}
  1. db>
  1. select find([2, 5, 7, 2, 100], 2, 1);
  1. {3}