Skip to content

Functions

/

Database functions

Type

Note

Since version 3.0.0-beta, the ::is:: functions (e.g. type::is::record()) now use underscores (e.g. type::is_record()) to better match the intent of the function and method syntax.

These functions can be used for generating and coercing data to specific data types. These functions are useful when accepting input values in client libraries, and ensuring that they are the desired type within SQL statements.

Function

Description

type::array()

Converts a value into an array

type::bool()

Converts a value into a boolean

type::bytes()

Converts a value into bytes

type::date()

Converts a value into a date

type::datetime()

Converts a value into a datetime

type::decimal()

Converts a value into a decimal

type::duration()

Converts a value into a duration

type::f16()

Converts a value into a 16-bit floating point number

type::f32()

Converts a value into a 32-bit floating point number

type::field()

Projects a single field within a SELECT statement

type::fields()

Projects a multiple fields within a SELECT statement

type::file()

Converts two strings into a file pointer

type::float()

Converts a value into a floating point number

type::i8()

Converts a value into an 8-bit signed integer

type::i16()

Converts a value into a 16-bit signed integer

type::i32()

Converts a value into a 32-bit signed integer

type::int()

Converts a value into an integer

type::interval()

Converts a value into an interval

type::number()

Converts a value into a number

type::of()

Returns the type of a value

type::point()

Converts a value into a geometry point

type::record()

Converts a value into a record pointer

type::string()

Converts a value into a string

type::table()

Converts a value into a table

type::time()

Converts a value into a time of day

type::timestamp()

Converts a value into a timestamp

type::range()

Converts a value into a range

type::u8()

Converts a value into an 8-bit unsigned integer

type::u16()

Converts a value into a 16-bit unsigned integer

type::u32()

Converts a value into a 32-bit unsigned integer

type::u64()

Converts a value into a 64-bit unsigned integer

type::uuid()

Converts a value into a UUID

type::is_array()

Checks if given value is of type array

type::is_bool()

Checks if given value is of type bool

type::is_bytes()

Checks if given value is of type bytes

type::is_collection()

Checks if given value is of type collection

type::is_date()

Checks if given value is of type date

type::is_datetime()

Checks if given value is of type datetime

type::is_decimal()

Checks if given value is of type decimal

type::is_duration()

Checks if given value is of type duration

type::is_f16()

Checks if given value is of type f16

type::is_f32()

Checks if given value is of type f32

type::is_float()

Checks if given value is of type float

type::is_geometry()

Checks if given value is of type geometry

type::is_i8()

Checks if given value is of type i8

type::is_i16()

Checks if given value is of type i16

type::is_i32()

Checks if given value is of type i32

type::is_int()

Checks if given value is of type int

type::is_interval()

Checks if given value is of type interval

type::is_line()

Checks if given value is of type line

type::is_none()

Checks if given value is of type none

type::is_null()

Checks if given value is of type null

type::is_multiline()

Checks if given value is of type multiline

type::is_multipoint()

Checks if given value is of type multipoint

type::is_multipolygon()

Checks if given value is of type multipolygon

type::is_number()

Checks if given value is of type number

type::is_object()

Checks if given value is of type object

type::is_point()

Checks if given value is of type point

type::is_polygon()

Checks if given value is of type polygon

type::is_range()

Checks if given value is of type range

type::is_record()

Checks if given value is of type record

type::is_string()

Checks if given value is of type string

type::is_time()

Checks if given value is of type time

type::is_timestamp()

Checks if given value is of type timestamp

type::is_u8()

Checks if given value is of type u8

type::is_u16()

Checks if given value is of type u16

type::is_u32()

Checks if given value is of type u32

type::is_u64()

Checks if given value is of type u64

type::is_uuid()

Checks if given value is of type uuid

The type::array function converts a value into an array.

API DEFINITION
type::array(array|range) -> array

The following example shows this function, and its output:

type::array(1..=3);
Output
[1, 2, 3]

This is the equivalent of using <array> to cast a value to an array.

The type::bool function converts a value into a boolean.

API DEFINITION
type::bool(bool|string) -> bool

The following example shows this function, and its output:

type::bool("true");
Output
true

This is the equivalent of using <bool> to cast a value to a boolean.


The type::bytes function converts a value into bytes.

API DEFINITION
type::bytes(bytes|string) -> bool

The following example shows this function, and its output:

type::bytes("A few bytes");
Output
b"4120666577206279746573"

This is the equivalent of using <bytes> to cast a value to bytes.


Available since: v4.0.0

The type::date function converts a value into a date.

API DEFINITION
type::date(date|datetime|timestamp|string) -> date

The following example shows this function, and its output:

[type::date('2026-10-27'), type::date(d'2026-10-27T12:30:45Z')];
Output
[pd'2026-10-27', pd'2026-10-27']

A datetime is converted to its date in UTC, so the time of day is dropped.

This is the equivalent of using <date> to cast a value. The method form is .to_date().


The type::datetime function converts a value into a datetime.

API DEFINITION
type::datetime(datetime|string) -> datetime

The following example shows this function, and its output:

type::datetime("2022-04-27T18:12:27+00:00");
Output
d'2022-04-27T18:12:27Z'

This is the equivalent of using <datetime> to cast a value to a datetime.


The type::decimal function converts a value into a decimal.

API DEFINITION
type::decimal(decimal|float|int|number|string) -> decimal

The following example shows this function, and its output:

type::decimal("12345");
Output
12345dec

This is the equivalent of using <decimal> to cast a value to a decimal.


The type::duration function converts a value into a duration.

API DEFINITION
type::duration(duration|string) -> duration

The following example shows this function, and its output:

type::duration("4h");
Output
4h

This is the equivalent of using <duration> to cast a value to a duration.


Available since: v4.0.0

The type::f16 function converts a value into a 16-bit floating point number. A value that is out of range for f16 is refused.

API DEFINITION
type::f16(decimal|float|int|number|string) -> f16

The following example shows this function, and its output:

type::f16(1.5);
Output
1.5f16

This is the equivalent of using <f16> to cast a value.


Available since: v4.0.0

The type::f32 function converts a value into a 32-bit floating point number. A value that is out of range for f32 is refused.

API DEFINITION
type::f32(decimal|float|int|number|string) -> f32

The following example shows this function, and its output:

type::f32(1.5);
Output
1.5f32

This is the equivalent of using <f32> to cast a value.


The type::field function projects a single field within a SELECT statement.

API DEFINITION
type::field(string)

The following example shows this function, and its output:

CREATE person:test SET title = 'Mr',
  name.first = 'Tobie',
  name.last = 'Morgan Hitchcock';

LET $param = 'name.first';

SELECT type::field($param), type::field('name.last') FROM person;

SELECT VALUE { 'firstname': type::field($param),
  lastname: type::field('name.last') } FROM person;

SELECT VALUE [type::field($param),
  type::field('name.last')] FROM person;
Output
[
	{
		id: person:test,
		title: 'Mr',
		name: {
			first: 'Tobie',
			last: 'Morgan Hitchcock',
	    }
	}
]


From SurrealDB 3.0, this function can be used after the OMIT clause of a SELECT statement.

LET $omit = "id";
CREATE person SET name = "Galen", surname = "Pathwarden", age = 19;
SELECT * OMIT type::field($omit) FROM person;
Output
[
	{
		age: 19,
		name: 'Galen',
		surname: 'Pathwarden'
	}
]


The type::fields function projects one or more fields within a SELECT statement.

API DEFINITION
type::fields(array<string>)

The following example shows this function, and its output:

CREATE person:test SET title = 'Mr',
  name.first = 'Tobie',
  name.last = 'Morgan Hitchcock';

LET $param = ['name.first', 'name.last'];

SELECT type::fields($param), type::fields(['title']) FROM person;

SELECT VALUE { 'names': type::fields($param) } FROM person;

SELECT VALUE type::fields($param) FROM person;
Output
[
	{
		id: person:test,
		title: 'Mr',
		name: {
			first: 'Tobie',
			last: 'Morgan Hitchcock',
		}
	}
]


From SurrealDB 3.0, this function can be used after the OMIT clause of a SELECT statement.

LET $omit = ["id", "age"];
CREATE person SET name = "Galen", surname = "Pathwarden", age = 19;
SELECT * OMIT type::fields($omit) FROM person;
Output
[
	{
		name: 'Galen',
		surname: 'Pathwarden'
	}
]


Available since: v3.0.0

The type::file function converts two strings representing a bucket name and a key into a file pointer.

API DEFINITION
type::file($bucket: string, $key: string) -> file

An example of a file pointer created using this function:

type::file("my_bucket", "file_name")
Output
f"my_bucket:/file_name"

The following query shows the equivalent file pointer when created using the f prefix:

type::file("my_bucket", "file_name") == f"my_bucket:/file_name";
Output
true

Once a bucket has been defined, operations using one of the file functions can be performed on the file pointer.

DEFINE BUCKET my_bucket BACKEND "memory";

type::file("my_bucket", "file_name").put("Some data inside");
type::file("my_bucket", "file_name").get();
Output
b"536F6D65206461746120696E73696465"


The type::float function converts a value into a float.

API DEFINITION
type::float(decimal|float|int|number|string) -> float

The following example shows this function, and its output:

type::float("12345");
Output
12345f

This is the equivalent of using <float> to cast a value to a float.


Available since: v4.0.0

The type::i8 function converts a value into an 8-bit signed integer. A value that is out of range for i8, or that has a fractional part, is refused.

API DEFINITION
type::i8(decimal|float|int|number|string) -> i8

The following example shows this function, and its output:

type::i8('-128');
Output
-128i8

This is the equivalent of using <i8> to cast a value.


Available since: v4.0.0

The type::i16 function converts a value into a 16-bit signed integer. A value that is out of range for i16, or that has a fractional part, is refused.

API DEFINITION
type::i16(decimal|float|int|number|string) -> i16

The following example shows this function, and its output:

type::i16(1000);
Output
1000i16

This is the equivalent of using <i16> to cast a value.


Available since: v4.0.0

The type::i32 function converts a value into a 32-bit signed integer. A value that is out of range for i32, or that has a fractional part, is refused.

API DEFINITION
type::i32(decimal|float|int|number|string) -> i32

The following example shows this function, and its output:

type::i32(100000);
Output
100000i32

This is the equivalent of using <i32> to cast a value.


The type::int function converts a value into an integer.

API DEFINITION
type::int(decimal|float|int|number|string) -> int

The following example shows this function, and its output:

type::int("12345");
Output
12345

This is the equivalent of using <int> to cast a value to an int.


Available since: v4.0.0

The type::interval function converts a value into an interval.

API DEFINITION
type::interval(interval|duration|time|string) -> interval

The following example shows this function, and its output:

[type::interval('2 days'), type::interval(1h30m)];
Output
[ivl'P2D', ivl'PT1H30M']

This is the equivalent of using <interval> to cast a value. The method form is .to_interval().


The type::number function converts a value into a number.

API DEFINITION
type::number(decimal|float|int|number|string) -> number

The following example shows this function, and its output:

type::number("12345");
Output
12345

This is the equivalent of using <number> to cast a value to a number.


Available since: v3.0.0

The type::of function returns a string denoting the type of a value.

API DEFINITION
type::of(value) -> string
type::of(2022dec);        -- 'decimal';
type::of(["some", 9]);    -- 'array';
type::of((50.0, 9.9));    -- 'geometry<point>'

The type::point function converts a value into a geometry point.

API DEFINITION
type::point(array|point) -> point

The following example shows this function, and its output:

type::point([ 51.509865, -0.118092 ]);
Output
(51.509865, -0.118092)


The type::range function converts a value into a range. It accepts a single argument, either a range or an array with two values. If the argument is an array, it will be converted into a range, similar to casting.

API DEFINITION
type::range(range|array) -> range<record>

The following example shows this function, and its output:

type::range([1, 2]);
//- 1..2

type::range(1..10);
//- 1..10

type::range([1,9,4]);
//- 'Expected a range but cannot convert [1, 9, 4] into a range'


Note

This function was known as type::thing in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::record function converts a value into a record pointer definition.

API DEFINITION
type::record($table: any, $key: any) -> record

The following example shows this function, and its output:

LET $tb = "person";
LET $id = "tobie";
RETURN type::record($tb, $id);

An example of this function being used to turn an array of objects into records to be created or upserted:

FOR $data IN [
	{
		id: 9,
		name: 'Billy'
	},
	{
		id: 10,
		name: 'Bobby'
	}
] {
	UPSERT type::record('person', $data.id) CONTENT $data;
};

An example of the same except in which the num field is to be used as the record's ID. In this case, it can be mapped with the array::map() function to rename num as id so that the following CONTENT clause does not create both a num and an id with the same value.

FOR $data IN [
	{
		name: 'Billy',
		num: 9
	},
    {
		name: 'Bobby',
		num: 10
	},
].map(|$o| {
    id: $o.num,
    name: $o.name
}) {
    UPSERT type::record('person', $data.id) CONTENT $data;
};

If the second argument passed into type::record is a record ID, the latter part of the ID (the record identifier) will be extracted and used.

type::record("person", person:mat);
Output
person:mat

The output of the above function call will thus be person:mat, not person:person:mat.

When the first argument is already a record ID and the second is a string, the string is treated as a table constraint: the function returns the record only if it belongs to that table, and errors otherwise. This form is common in access-control clauses such as SELECT * FROM type::record($id, "user"), where $id must be a user record and not an ID from another table.

type::record(person:tobie, 'person'); -- person:tobie
type::record(person:tobie, 'cat');
Output
error: record is not in table `cat`


The type::string function converts any value except NONE, NULL, and bytes into a string.

API DEFINITION
type::string(any) -> string

The following example shows this function, and its output:

type::string(12345);
Output
'12345'

This is the equivalent of using <string> to cast a value to a string.


Available since: v3.0.0

The type::string_lossy function converts any value except NONE, NULL, and bytes into a string. In the case of bytes, it will not return an error if the bytes are not valid UTF-8. Instead, invalid bytes will be replaced with the character � (U+FFFD REPLACEMENT CHARACTER, used in Unicode to represent a decoding error).

API DEFINITION
type::string(any) -> string

The following example shows this function, and its output:

-- Contains some invalid bytes
type::string_lossy(<bytes>[83,
  117,
  114,
  255,
  114,
  101,
  97,
  254,
  108,
  68,
  66]);
-- valid bytes
type::string_lossy(<bytes>[ 83,
  117,
  114,
  114,
  101,
  97,
  108,
  68,
  66 ]);
Output
-------- Query --------

'Sur�rea�lDB'

-------- Query --------

'SurrealDB'

This is similar to using <string> to cast a value to a string, except that an input of bytes will not fail.


The type::table function converts a value into a table name.

API DEFINITION
type::table(record|string) -> string

The following example shows this function, and its output:

[
  type::table("person"),
  type::table(cat:one)
];
Output
[person, cat]

As of version 2.0, SurrealDB no longer eagerly parses strings into record IDs. As such, the output of the last item ("dog:two") in the following example will differ. In version 1.x, it will be eagerly parsed into a record ID after which the dog table name will be returned, while in later editions it will be treated as a string and converted into the table name dog:two. As of version 3.0, a number is no longer accepted as input, because a number on its own is not a valid table name.

[
  type::table(cat:one),
  type::table("dog"),
  type::table("dog:two"),
];
Output
[
	cat,
	dog,
	`dog:two`
]


Available since: v4.0.0

The type::time function converts a value into a time of day.

API DEFINITION
type::time(time|datetime|timestamp|string) -> time

The following example shows this function, and its output:

[type::time('12:30:00'), type::time(d'2026-10-27T12:30:45Z')];
Output
[pt'12:30:00', pt'12:30:45']

This is the equivalent of using <time> to cast a value. The method form is .to_time().


Available since: v4.0.0

The type::timestamp function converts a value into a timestamp.

API DEFINITION
type::timestamp(timestamp|date|datetime|string) -> timestamp

The following example shows this function, and its output:

[type::timestamp('2026-10-27T12:30:00'), type::timestamp(pd'2026-10-27')];
Output
[ts'2026-10-27T12:30:00', ts'2026-10-27T00:00:00']

This is the equivalent of using <timestamp> to cast a value. The method form is .to_timestamp().


Available since: v4.0.0

The type::u8 function converts a value into an 8-bit unsigned integer. A value that is out of range for u8, or that has a fractional part, is refused.

API DEFINITION
type::u8(decimal|float|int|number|string) -> u8

The following example shows this function, and its output:

type::u8(255);
Output
255u8

This is the equivalent of using <u8> to cast a value.


Available since: v4.0.0

The type::u16 function converts a value into a 16-bit unsigned integer. A value that is out of range for u16, or that has a fractional part, is refused.

API DEFINITION
type::u16(decimal|float|int|number|string) -> u16

The following example shows this function, and its output:

type::u16(1000);
Output
1000u16

This is the equivalent of using <u16> to cast a value.


Available since: v4.0.0

The type::u32 function converts a value into a 32-bit unsigned integer. A value that is out of range for u32, or that has a fractional part, is refused.

API DEFINITION
type::u32(decimal|float|int|number|string) -> u32

The following example shows this function, and its output:

type::u32(100000);
Output
100000u32

This is the equivalent of using <u32> to cast a value.


Available since: v4.0.0

The type::u64 function converts a value into a 64-bit unsigned integer. A value that is out of range for u64, or that has a fractional part, is refused.

API DEFINITION
type::u64(decimal|float|int|number|string) -> u64

The following example shows this function, and its output:

type::u64('18446744073709551615');
Output
18446744073709551615u64

This is the equivalent of using <u64> to cast a value.


The type::uuid function converts a value into a UUID.

API DEFINITION
type::uuid(string|uuid) -> uuid

The following example shows this function, and its output:

type::uuid("0191f946-936f-7223-bef5-aebbc527ad80");
Output
u'0191f946-936f-7223-bef5-aebbc527ad80'


Note

This function was known as type::is::array in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_array function checks if the passed value is of type array.

API DEFINITION
type::is_array(any) -> bool

The following example shows this function, and its output:

type::is_array([ 'a', 'b', 'c' ]);
Output
true


Note

This function was known as type::is::bool in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_bool function checks if the passed value is of type bool.

API DEFINITION
type::is_bool(any) -> bool

The following example shows this function, and its output:

type::is_bool(true);
Output
true


Note

This function was known as type::is::bytes in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_bytes function checks if the passed value is of type bytes.

API DEFINITION
type::is_bytes(any) -> bool

The following example shows this function, and its output:

type::is_bytes("I am not bytes");
Output
false


Note

This function was known as type::is::collection in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_collection function checks if the passed value is of type collection.

API DEFINITION
type::is_collection(any) -> bool

The following example shows this function, and its output:

type::is_collection("I am not a collection");
Output
false


Available since: v4.0.0

The type::is_date function checks if the passed value is of type date.

API DEFINITION
type::is_date(any) -> bool

The following example shows this function, and its output:

[type::is_date(pd'2026-10-27'), type::is_date(d'2026-10-27')];
Output
[true, false]


Note

This function was known as type::is::datetime in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_datetime function checks if the passed value is of type datetime.

API DEFINITION
type::is_datetime(any) -> bool

The following example shows this function, and its output:

type::is_datetime(time::now());
Output
true


Note

This function was known as type::is::decimal in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_decimal function checks if the passed value is of type decimal.

API DEFINITION
type::is_decimal(any) -> bool

The following example shows this function, and its output:

type::is_decimal(<decimal>
  13.5719384719384719385639856394139476937756394756);
Output
true


Note

This function was known as type::is::duration in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_duration function checks if the passed value is of type duration.

API DEFINITION
type::is_duration(any) -> bool

The following example shows this function, and its output:

type::is_duration('1970-01-01T00:00:00');
Output
false


Available since: v4.0.0

The type::is_f16 function checks if the passed value is of type f16.

API DEFINITION
type::is_f16(any) -> bool

The following example shows this function, and its output:

type::is_f16(1.5f16);
Output
true


Available since: v4.0.0

The type::is_f32 function checks if the passed value is of type f32.

API DEFINITION
type::is_f32(any) -> bool

The following example shows this function, and its output:

type::is_f32(1.5f32);
Output
true


Note

This function was known as type::is::float in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_float function checks if the passed value is of type float. From SurrealDB 4.0, a sized float such as 1.5f32 is not of type float, so this function returns false for it. Use type::is_number() to accept a number of any type.

API DEFINITION
type::is_float(any) -> bool

The following example shows this function, and its output:

type::is_float(<float> 41.5);
Output
true


Note

This function was known as type::is::geometry in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_geometry function checks if the passed value is of type geometry.

API DEFINITION
type::is_geometry(any) -> bool

The following example shows this function, and its output:

type::is_geometry((-0.118092, 51.509865));
Output
true


Available since: v4.0.0

The type::is_i8 function checks if the passed value is of type i8.

API DEFINITION
type::is_i8(any) -> bool

The following example shows this function, and its output:

type::is_i8(5i8);
Output
true


Available since: v4.0.0

The type::is_i16 function checks if the passed value is of type i16.

API DEFINITION
type::is_i16(any) -> bool

The following example shows this function, and its output:

type::is_i16(5i16);
Output
true


Available since: v4.0.0

The type::is_i32 function checks if the passed value is of type i32.

API DEFINITION
type::is_i32(any) -> bool

The following example shows this function, and its output:

type::is_i32(5i32);
Output
true


Note

This function was known as type::is::int in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_int function checks if the passed value is of type int. From SurrealDB 4.0, a sized integer such as 5u8 or 5u64 is not of type int, so this function returns false for it. Use type::is_number() to accept a number of any type.

API DEFINITION
type::is_int(any) -> bool

The following example shows this function, and its output:

type::is_int(<int> 123);
Output
true


Available since: v4.0.0

The type::is_interval function checks if the passed value is of type interval.

API DEFINITION
type::is_interval(any) -> bool

The following example shows this function, and its output:

[type::is_interval(ivl'1 day'), type::is_interval(1d)];
Output
[true, false]


Note

This function was known as type::is::line in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_line function checks if the passed value is of type line.

API DEFINITION
type::is_line(any) -> bool

The following example shows this function, and its output:

type::is_line("I am not a line");
Output
false


Note

This function was known as type::is::none in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_none function checks if the passed value is of type none.

API DEFINITION
type::is_none(any) -> bool

The following example shows this function, and its output:

type::is_none(NONE);
Output
true


Note

This function was known as type::is::null in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_null function checks if the passed value is of type null.

API DEFINITION
type::is_null(any) -> bool

The following example shows this function, and its output:

type::is_null(NULL);
Output
true


Note

This function was known as type::is::multiline in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_multiline function checks if the passed value is of type multiline.

API DEFINITION
type::is_multiline(any) -> bool

The following example shows this function, and its output:

type::is_multiline("I am not a multiline");
Output
false


Note

This function was known as type::is::multipoint in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_multipoint function checks if the passed value is of type multipoint.

API DEFINITION
type::is_multipoint(any) -> bool

The following example shows this function, and its output:

type::is_multipoint("I am not a multipoint");
Output
false


Note

This function was known as type::is::multipolygon in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_multipolygon function checks if the passed value is of type multipolygon.

API DEFINITION
type::is_multipolygon(any) -> bool

The following example shows this function, and its output:

type::is_multipolygon("I am not a multipolygon");
Output
false


Note

This function was known as type::is::number in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_number function checks if the passed value is of type number.

API DEFINITION
type::is_number(any) -> bool

The following example shows this function, and its output:

type::is_number(123);
Output
true


Note

This function was known as type::is::object in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_object function checks if the passed value is of type object.

API DEFINITION
type::is_object(any) -> bool

The following example shows this function, and its output:

type::is_object({ hello: 'world' });
Output
true


Note

This function was known as type::is::point in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_point function checks if the passed value is of type point.

API DEFINITION
type::is_point(any) -> bool

The following example shows this function, and its output:

type::is_point((-0.118092, 51.509865));
Output
true


Note

This function was known as type::is::polygon in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_polygon function checks if the passed value is of type polygon.

API DEFINITION
type::is_polygon(any) -> bool

The following example shows this function, and its output:

type::is_polygon("I am not a polygon");
Output
false
Note

This function was known as type::is::range in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_range function checks if the passed value is of type range.

API DEFINITION
type::is_range(any) -> bool
type::is_range(0..1);
//- true

-- method syntax
(0..1).is_range();
//- true
Note

This function was known as type::is::record in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_record function checks if the passed value is of type record.

API DEFINITION
type::is_record(any) -> bool

The following example shows this function, and its output:

type::is_record(user:tobie);
Output
true
Check if user:tobie is a record on the test table
type::is_record(user:tobie, 'test');

-- false


Note

This function was known as type::is::string in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_string function checks if the passed value is of type string.

API DEFINITION
type::is_string(any) -> bool

The following example shows this function, and its output:

type::is_string("abc");
Output
true


Available since: v4.0.0

The type::is_time function checks if the passed value is of type time.

API DEFINITION
type::is_time(any) -> bool

The following example shows this function, and its output:

[type::is_time(pt'12:30:00'), type::is_time(12h)];
Output
[true, false]


Available since: v4.0.0

The type::is_timestamp function checks if the passed value is of type timestamp.

API DEFINITION
type::is_timestamp(any) -> bool

The following example shows this function, and its output:

[type::is_timestamp(ts'2026-10-27T12:30:00'), type::is_timestamp(pd'2026-10-27')];
Output
[true, false]


Available since: v4.0.0

The type::is_u8 function checks if the passed value is of type u8. A number of another type with the same value, such as 5 or 5u16, is not a u8.

API DEFINITION
type::is_u8(any) -> bool

The following example shows this function, and its output:

type::is_u8(5);
Output
false


Available since: v4.0.0

The type::is_u16 function checks if the passed value is of type u16.

API DEFINITION
type::is_u16(any) -> bool

The following example shows this function, and its output:

type::is_u16(5u16);
Output
true


Available since: v4.0.0

The type::is_u32 function checks if the passed value is of type u32.

API DEFINITION
type::is_u32(any) -> bool

The following example shows this function, and its output:

type::is_u32(5u32);
Output
true


Available since: v4.0.0

The type::is_u64 function checks if the passed value is of type u64.

API DEFINITION
type::is_u64(any) -> bool

The following example shows this function, and its output:

type::is_u64(5u64);
Output
true


Note

This function was known as type::is::uuid in versions of SurrealDB before 3.0.0. The behaviour has not changed.

The type::is_uuid function checks if the passed value is of type uuid.

API DEFINITION
type::is_uuid(any) -> bool

The following example shows this function, and its output:

type::is_uuid(u"018a6680-bef9-701b-9025-e1754f296a0f");
Output
true



Method chaining allows functions to be called using the . dot operator on a value of a certain type instead of the full path of the function followed by the value.

-- Traditional syntax
type::is_record(r"person:aeon", "cat");

-- Method chaining syntax
r"person:aeon".is_record("cat");
Output
false

Was this page helpful?