SurrealDB
SurrealDB Docs Logo

Enter a search query

Data Types

This SDK facilitates communication between client and the backend service using the Concise Binary Object Representation (CBOR) format. It streamlines data serialization and deserialization while ensuring efficient and lightweight communication. The library also provides custom models tailored to specific Data models recognised by SurrealDb, which cannot be covered by idiomatic Go, enabling seamless interaction between the client and the backend.

Data Types overview

CBOR TypeGo RepresentationExample
Nullnilvar x interface{} = nil
Nonesurrealdb.Nonemap[string]interface{}{"customer": surrealdb.None}
Booleanbooltrue, false
Array[]interface{}[]MyStruct{item1, item2}
Date/Timetime.Timetime.Now()
Durationtime.Durationtime.Duration(8821356)
UUID (string representation)surrealdb.UUID(string)surrealdb.UUID("123e4567-e89b-12d3-a456-426614174000")
UUID (binary representation)surrealdb.UUIDBin([]bytes)surrealdb.UUIDBin([]byte{0x01, 0x02, ...})`
Integeruint, uint64, int, int6442, uint64(100000), -42, int64(-100000)
Floating Pointfloat32, float643.14, float64(2.71828)
Byte String, Binary Encoded Data[]byte[]byte{0x01, 0x02}
Text Stringstring"Hello, World!"
Mapmap[interface{}]interface{}map[string]float64{"one": 1.0}
Table namesurrealdb.Table(name)surrealdb.Table("users")
Record IDsurrealdb.RecordID{Table: string, ID: interface{}}surrealdb.RecordID{Table: "customers", ID: 1}, surrealdb.NewRecordID("customers", 1)
Geometry Pointsurrealdb.GeometryPoint{Latitude: float64, Longitude: float64}surrealdb.GeometryPoint{Latitude: 11.11, Longitude: 22.22
Geometry Linesurrealdb.GeometryLine{GeometricPoint1, GeometricPoint2,... }
Geometry Polygonsurrealdb.GeometryPolygon{GeometryLine1, GeometryLine2,... }
Geometry Multipointsurrealdb.GeometryMultiPoint{GeometryPoint1, GeometryPoint2,... }
Geometry MultiLinesurrealdb.GeometryMultiLine{GeometryLine1, GeometryLine2,... }
Geometry MultiPolygonsurrealdb.GeometryMultiPolygon{GeometryPolygon1, GeometryPolygon2,... }
Geometry Collectionsurrealdb.GeometryMultiPolygon{GeometryPolygon1, GeometryLine2, GeometryPoint3, GeometryMultiPoint4,... }


Encoding

The SDK uses CBOR for all client-server serialization. It does not use encoding/json, and MarshalJSON is not part of the serialization path.

Both implementations are supported; choose the one that fits your needs/performance characteristics.

Edit this page on GitHub