# Type

These functions can be used for generating and coercing data to specific data types.

> [!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.

<table>
  <thead>
    <tr>
      <th scope="col">Function</th>
      <th scope="col">Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td scope="row" data-label="Function"><a href="#typearray"><code>type::array()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into an array</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typebool"><code>type::bool()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a boolean</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typebytes"><code>type::bytes()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into bytes</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typedatetime"><code>type::datetime()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a datetime</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typedecimal"><code>type::decimal()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a decimal</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeduration"><code>type::duration()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a duration</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typefield"><code>type::field()</code></a></td>
      <td scope="row" data-label="Description">Projects a single field within a SELECT statement</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typefields"><code>type::fields()</code></a></td>
      <td scope="row" data-label="Description">Projects a multiple fields within a SELECT statement</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typefile"><code>type::file()</code></a></td>
      <td scope="row" data-label="Description">Converts two strings into a file pointer</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typefloat"><code>type::float()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a floating point number</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeint"><code>type::int()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into an integer</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typenumber"><code>type::number()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a number</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeof"><code>type::of()</code></a></td>
      <td scope="row" data-label="Description">Returns the type of a value</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typepoint"><code>type::point()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a geometry point</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typerecord"><code>type::record()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a record pointer</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typestring"><code>type::string()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a string</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typetable"><code>type::table()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a table</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typerange"><code>type::range()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a range</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeuuid"><code>type::uuid()</code></a></td>
      <td scope="row" data-label="Description">Converts a value into a UUID</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_array"><code>type::is_array()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type array</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_bool"><code>type::is_bool()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type bool</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_bytes"><code>type::is_bytes()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type bytes</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_collection"><code>type::is_collection()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type collection</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_datetime"><code>type::is_datetime()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type datetime</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_decimal"><code>type::is_decimal()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type decimal</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_duration"><code>type::is_duration()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type duration</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_float"><code>type::is_float()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type float</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_geometry"><code>type::is_geometry()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type geometry</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_int"><code>type::is_int()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type int</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_line"><code>type::is_line()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type line</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_none"><code>type::is_none()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type none</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_null"><code>type::is_null()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type null</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_multiline"><code>type::is_multiline()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type multiline</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_multipoint"><code>type::is_multipoint()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type multipoint</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_multipolygon"><code>type::is_multipolygon()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type multipolygon</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_number"><code>type::is_number()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type number</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_object"><code>type::is_object()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type object</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_point"><code>type::is_point()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type point</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_polygon"><code>type::is_polygon()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type polygon</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_polygon"><code>type::is_range()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type range</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_record"><code>type::is_record()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type record</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_string"><code>type::is_string()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type string</td>
    </tr>
    <tr>
      <td scope="row" data-label="Function"><a href="#typeis_uuid"><code>type::is_uuid()</code></a></td>
      <td scope="row" data-label="Description">Checks if given value is of type uuid</td>
    </tr>
  </tbody>
</table>

## `type::array`

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

```surql title="API DEFINITION"
type::array(array|range) -> array
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::array(1..=3);

-- [1, 2, 3]
```

This is the equivalent of using [`<array>`](/docs/reference/query-language/language-primitives/casting.md#array) to cast a value to an array.

## `type::bool`

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

```surql title="API DEFINITION"
type::bool(bool|string) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::bool("true");

-- true
```

This is the equivalent of using [`<bool>`](/docs/reference/query-language/language-primitives/casting.md#bool) to cast a value to a boolean.

<br />

## `type::bytes`

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

```surql title="API DEFINITION"
type::bytes(bytes|string) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::bytes("A few bytes");

-- b"4120666577206279746573"
```

This is the equivalent of using [`<bytes>`](/docs/reference/query-language/language-primitives/casting.md) to cast a value to bytes.

<br />

## `type::datetime`

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

```surql title="API DEFINITION"
type::datetime(datetime|string) -> datetime
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::datetime("2022-04-27T18:12:27+00:00");

-- d'2022-04-27T18:12:27Z'
```

This is the equivalent of using [`<datetime>`](/docs/reference/query-language/language-primitives/casting.md#datetime) to cast a value to a datetime.

<br />

## `type::decimal`

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

```surql title="API DEFINITION"
type::decimal(decimal|float|int|number|string) -> decimal
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::decimal("12345");

-- 12345dec
```

This is the equivalent of using [`<decimal>`](/docs/reference/query-language/language-primitives/casting.md#decimal) to cast a value to a decimal.

<br />

## `type::duration`

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

```surql title="API DEFINITION"
type::duration(duration|string) -> duration
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::duration("4h");

-- 4h
```

This is the equivalent of using [`<duration>`](/docs/reference/query-language/language-primitives/casting.md#duration) to cast a value to a duration.

<br />

## `type::field`

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

```surql title="API DEFINITION"
type::field(string)
```
The following example shows this function, and its output:

```surql
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;
```

```surql title="Output"
[
	{
		id: person:test,
		title: 'Mr',
		name: {
			first: 'Tobie',
			last: 'Morgan Hitchcock',
	    }
	}
]
```

<br/>

_(since v3.0.0)_

This function can be used after the `OMIT` clause of a `SELECT` statement.

```surql
LET $omit = "id";
CREATE person SET name = "Galen", surname = "Pathwarden", age = 19;
SELECT * OMIT type::field($omit) FROM person;
```

```surql title="Output"
[
	{
		age: 19,
		name: 'Galen',
		surname: 'Pathwarden'
	}
]
```

<br />

## `type::fields`

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

```surql title="API DEFINITION"
type::fields(array<string>)
```
The following example shows this function, and its output:

```surql
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;
```

```surql title="Output"
[
	{
		id: person:test,
		title: 'Mr',
		name: {
			first: 'Tobie',
			last: 'Morgan Hitchcock',
		}
	}
]
```

<br/>

_(since v3.0.0)_

This function can be used after the `OMIT` clause of a `SELECT` statement.

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

```surql title="Output"
[
	{
		name: 'Galen',
		surname: 'Pathwarden'
	}
]
```

<br />

## `type::file`

_(since v3.0.0)_

The `type::file` function converts two strings representing a bucket name and a key into a [file pointer](/docs/reference/query-language/language-primitives/data-types/files.md).

```surql title="API DEFINITION"
type::file($bucket: string, $key: string) -> file
```

An example of a file pointer created using this function:

```surql
type::file("my_bucket", "file_name")
```

```surql title="Output"
f"my_bucket:/file_name"
```

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

```surql
type::file("my_bucket", "file_name") == f"my_bucket:/file_name";

-- true
```

Once a [bucket has been defined](/docs/reference/query-language/statements/define/indexes.md), operations using one of the [file functions](/docs/reference/query-language/functions/database-functions/file.md) can be performed on the file pointer.

```surql
DEFINE BUCKET my_bucket BACKEND "memory";

type::file("my_bucket", "file_name").put("Some data inside");
type::file("my_bucket", "file_name").get();
```

```surql title="Output"
b"536F6D65206461746120696E73696465"
```

<br />

## `type::float`

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

```surql title="API DEFINITION"
type::float(decimal|float|int|number|string) -> float
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::float("12345");

-- 12345f
```
This is the equivalent of using [`<float>`](/docs/reference/query-language/language-primitives/casting.md#float) to cast a value to a float.

<br />

## `type::int`

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

```surql title="API DEFINITION"
type::int(decimal|float|int|number|string) -> int
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::int("12345");

-- 12345
```
This is the equivalent of using [`<int>`](/docs/reference/query-language/language-primitives/casting.md#int) to cast a value to a int.

<br />

## `type::number`

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

```surql title="API DEFINITION"
type::number(decimal|float|int|number|string) -> number
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::number("12345");

-- 12345
```

This is the equivalent of using [`<number>`](/docs/reference/query-language/language-primitives/casting.md#number) to cast a value to a number.

<br />

## `type:of`

_(since v3.0.0)_

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

```surql title="API DEFINITION"
type::of(value) -> string
```

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

## `type::point`

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

```surql title="API DEFINITION"
type::point(array|point) -> point
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::point([ 51.509865, -0.118092 ]);

-- (51.509865, -0.118092)
```

<br />

## `type::range`

The `type::range` function converts a value into a [range](/docs/reference/query-language/language-primitives/data-types/ranges.md). 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](/docs/reference/query-language/language-primitives/casting.md).

```surql title="API DEFINITION"
type::range(range|array) -> range<record>
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::range([1, 2]);
-- 1..2

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

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

<br />

## `type::record`

**3.x**

> [!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.

```surql title="API DEFINITION"
type::record($table: any, $key: any) -> record
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
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:

```surql
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()`](/docs/reference/query-language/functions/database-functions/array.md#arraymap) 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.

```surql
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.

```surql
type::record("person", person:mat);

-- 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.

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

**2.x**

The `type::record` function returns a record from a record or a string, with an optional argument to confirm the table name.

```surql title="API DEFINITION"
type::record($record: record|string,
  $table_name: option<string>) -> record
```

The function will return a record as long as the argument passed in is already a record, or a string that can be parsed into one.

```surql
-- Both return person:tobie
type::record(person:tobie);
type::record('person:tobie');
```

The optional second argument allows an assertation that the record passed in is of this table name.

```surql
type::record('person:tobie', 'person'); -- person:tobie
type::record('person:tobie', 'cat');
-- "Expected a record<cat> but cannot convert 'person:tobie' into a
  record<cat>"
```

This second argument is mostly useful when involving a parameter that may or may not be a certain value. In the code below, the function may or may not err depending on whether the `$record` parameter is a `person` or a `cat` record.

```surql
LET $record = rand::enum(person:tobie, cat:tobie);
type::record($record, 'person');
```

<br/>

## `type::string`

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

```surql title="API DEFINITION"
type::string(any) -> string
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::string(12345);

-- '12345'
```

This is the equivalent of using [`<string>`](/docs/reference/query-language/language-primitives/casting.md#string) to cast a value to a string.

<br />

## `type::string_lossy`

_(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).

```surql title="API DEFINITION"
type::string(any) -> string
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
-- 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 ]);
```

```surql title="Output"
-------- Query --------

'Sur�rea�lDB'

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

'SurrealDB'
```

This is similar to using [`<string>`](/docs/reference/query-language/language-primitives/casting.md#string) to cast a value to a string, except that an input of bytes will not fail.

<br />

## `type::table`

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

```surql title="API DEFINITION"
type::table(record|string) -> string
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN [
  type::table("person"),
  type::table(cat:one)
];

-- [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`.

```surql
RETURN [
  type::table(55),
  type::table(cat:one),
  type::table("dog"),
  type::table("dog:two"),
];
```

```surql title="Output"
[
	`55`,
	cat,
	dog,
	`dog:two`
]
```

<br />

## `type::uuid`

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

```surql title="API DEFINITION"
type::uuid(string|uuid) -> uuid
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::uuid("0191f946-936f-7223-bef5-aebbc527ad80");

-- u'0191f946-936f-7223-bef5-aebbc527ad80'
```
<br />

## `type::is_array`

> [!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`.

```surql title="API DEFINITION"
type::is_array(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_array([ 'a', 'b', 'c' ]);

-- true
```

<br />

## `type::is_bool`

> [!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`.

```surql title="API DEFINITION"
type::is_bool(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_bool(true);

-- true
```

<br />

## `type::is_bytes`

> [!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`.

```surql title="API DEFINITION"
type::is_bytes(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_bytes("I am not bytes");

-- false
```

<br />

## `type::is_collection`

> [!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`.

```surql title="API DEFINITION"
type::is_collection(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_collection("I am not a collection");

-- false
```

<br />

## `type::is_datetime`

> [!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`.

```surql title="API DEFINITION"
type::is_datetime(any) -> bool
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_datetime(time::now());

-- true
```

<br />

## `type::is_decimal`

> [!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`.

```surql title="API DEFINITION"
type::is_decimal(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_decimal(<decimal>
  13.5719384719384719385639856394139476937756394756);

-- true
```

<br />

## `type::is_duration`

> [!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`.

```surql title="API DEFINITION"
type::is_duration(any) -> bool
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_duration('1970-01-01T00:00:00');

-- false
```

<br />

## `type::is_float`

> [!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`.

```surql title="API DEFINITION"
type::is_float(any) -> bool
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_float(<float> 41.5);

-- true
```

<br />

## `type::is_geometry`

> [!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`.

```surql title="API DEFINITION"
type::is_geometry(any) -> bool
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_geometry((-0.118092, 51.509865));

-- true
```

<br />

## `type::is_int`

> [!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`.

```surql title="API DEFINITION"
type::is_int(any) -> bool
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_int(<int> 123);

-- true
```

<br />

## `type::is_line`

> [!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`.

```surql title="API DEFINITION"
type::is_line(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_line("I am not a line");

-- false
```

<br />

## `type::is_none`

> [!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`.

```surql title="API DEFINITION"
type::is_none(any) -> bool
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_none(NONE);

-- true
```

<br />

## `type::is_null`

> [!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`.

```surql title="API DEFINITION"
type::is_null(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_null(NULL);

-- true
```

<br />

## `type::is_multiline`

> [!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`.

```surql title="API DEFINITION"
type::is_multiline(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_multiline("I am not a multiline");

-- false
```

<br />

## `type::is_multipoint`

> [!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`.

```surql title="API DEFINITION"
type::is_multipoint(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_multipoint("I am not a multipoint");

-- false
```

<br />

## `type::is_multipolygon`

> [!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`.

```surql title="API DEFINITION"
type::is_multipolygon(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_multipolygon("I am not a multipolygon");

-- false
```

<br />

## `type::is_number`

> [!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`.

```surql title="API DEFINITION"
type::is_number(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_number(123);

-- true
```

<br />

## `type::is_object`

> [!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`.

```surql title="API DEFINITION"
type::is_object(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_object({ hello: 'world' });

-- true
```

<br />

## `type::is_point`

> [!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`.

```surql title="API DEFINITION"
type::is_point(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_point((-0.118092, 51.509865));

-- true
```

<br />

## `type::is_polygon`

> [!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`.

```surql title="API DEFINITION"
type::is_polygon(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_polygon("I am not a polygon");

-- false
```

## `type::is_range`

> [!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`.

```surql title="API DEFINITION"
type::is_range(any) -> bool
```

```surql
type::is_range(0..1);
-- true

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

## `type::is_record`

> [!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`.

```surql title="API DEFINITION"
type::is_record(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_record(user:tobie);

-- true
```

### Validate a table

```surql title="Check if user:tobie is a record on the test table"
RETURN type::is_record(user:tobie, 'test');

-- false
```

<br />

## `type::is_string`

> [!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`.

```surql title="API DEFINITION"
type::is_string(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_string("abc");

-- true
```

<br />

## `type::is_uuid`

> [!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`.

```surql title="API DEFINITION"
type::is_uuid(any) -> bool
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/reference/query-language/statements/return.md) statement:

```surql
RETURN type::is_uuid(u"018a6680-bef9-701b-9025-e1754f296a0f");

-- true
```

<br /><br />

## Method chaining

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.

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

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

```surql title="Response"
false
```
