@ -13,6 +13,7 @@ A runtime value in Cozo can be of the following *value-types*:
* ``Number``
* ``String``
* ``Bytes``
* ``Uuid``
* ``List``
``Number`` can be ``Float`` (double precision) or ``Int`` (signed, 64 bits). Cozo will auto-promote ``Int`` to ``Float`` when necessary.
@ -28,6 +29,7 @@ Within each type values are *compared* according to logic custom to each type:
* Lists are ordered lexicographically by their elements;
* Bytes are compared lexicographically;
* Strings are ordered lexicographically by their UTF-8 byte representations.
* If two UUIDs are both of version one, they are compared based on their timestamp. Otherwise, or when the timestamp comparison results in a tie, they are compared by their bytes.
* ``E`` is converted to the base of natural logarithms, or Euler's constant (2.71828...).
..function:: to_uuid(x)
Tries to convert ``x`` to a UUID. The input must either be a hyphenated UUID string representation or already a UUID for it to succeed.
..function:: uuid_timestamp(x)
Extracts the timestamp from a UUID version 1, as nanoseconds since the UNIX epoch divided by 100. If the UUID is not of version 1, ``null`` is returned. If ``x`` is not a UUID, an error is raised.
..function:: is_null(x)
@ -506,6 +513,10 @@ Type checking and conversions
Checks for strings.
..function:: is_uuid(x)
Checks for UUIDs.
-----------------
Random functions
-----------------
@ -529,6 +540,13 @@ Random functions
Randomly chooses an element from ``list`` and returns it. If the list is empty, it returns ``null``.
..function:: rand_uuid_v1()
Generate a random UUID, version 1 (random bits plus timestamp).
..function:: rand_uuid_v4()
Generate a random UUID, version 4 (completely random bits).