The JavaScript SDK provides custom classes for SurrealDB-specific data types, ensuring type safety and data integrity when working with the database. For a conceptual overview with usage examples and best practices, see the Value types concept page.
RecordId - Type-safe record identifiers with table and ID components
new RecordId(table, id) - Create record IDRecordId.parse(string) - Parse from stringRecordIdRange for querying rangesTable - Type-safe table references
new Table<T>(name) - Create typed table referenceDateTime - Datetime values with nanosecond precision
DateTime.now() - Current datetimeDateTime.parse(string) - Parse from ISO string.toDate() - Convert to JavaScript DateDuration - Time duration with support for multiple units
Duration.parse('5h30m') - Parse from string.toMilliseconds() - Convert to millisecondsDecimal - Arbitrary precision decimal numbers
new Decimal('19.99') - Create precise decimalUuid - Universally unique identifiers
Uuid.v4() - Generate random UUIDUuid.v7() - Generate time-ordered UUIDRange - Generic range values for numeric and date ranges
FileRef - References to files stored in SurrealDB
.bucket - Storage bucket name.key - File key within the bucketGeometryPoint - Single pointGeometryLine - Line between pointsGeometryPolygon - Polygon shapeGeometryMultiPoint, GeometryMultiLine, GeometryMultiPolygonGeometryCollection - Mixed geometry collection