• Start

Concepts

Value types

The SurrealDB tagged value types that the Mojo SDK encodes and decodes.

The Mojo SDK ships CBOR encoders and decoders for the SurrealDB tagged value types. These types live in the surrealdb.value module and map directly onto the values SurrealDB stores and returns.

A RecordId pairs a table with a record key. Its to_string() returns the canonical table:id form.

from surrealdb import RecordId, Table

var id = RecordId(Table("person"), "chiru")
print(id.to_string())  # person:chiru

Table wraps a table name on its own.

Type

Fields

Description

Uuidvalue

A UUID string.

DateTimeseconds

,

nanos

A point in time, split into seconds and nanoseconds.

Durationseconds

,

nanos

A length of time.

Decimalvalue

An arbitrary-precision decimal, held as a string.

FileRefbucket

,

key

A reference to a file in a bucket.

SurrealSetitems

A set of values.

FutureValuebody

A computed (future) value, held as its expression body.

A RangeValue describes a bounded range. Its bounds are BoundIncluded or BoundExcluded, set on the begin_included, begin_excluded, end_included, and end_excluded fields.

The SDK models the full GeoJSON family:

  • GeometryPoint with longitude and latitude.

  • GeometryLine and GeometryPolygon.

  • GeometryMultiPoint, GeometryMultiLine, and GeometryMultiPolygon.

  • GeometryCollection, holding points, lines, and polygons together.

from surrealdb import GeometryPoint

var here = GeometryPoint(-0.118092, 51.509865)

Was this page helpful?