UUID

The UUID struct wraps the github.com/gofrs/uuid package and handles CBOR encoding with tag 37 as specified by SurrealDB. It supports both UUID v4 and v7 values.

Package: github.com/surrealdb/surrealdb.go/pkg/models

Source: pkg/models/uuid.go

Definition

type UUID struct {
uuid.UUID
}

UUID embeds github.com/gofrs/uuid.UUID, so all methods from that package are available directly.

UUIDString

A string type for UUID values that prefer string representation. Encoded with CBOR tag 9.

type UUIDString string

CBOR Encoding

UUID is encoded as CBOR tag 37 containing the 16-byte binary representation. UUIDString is encoded as CBOR tag 9 containing the string representation.

Usage

UUID is returned by live query functions and session/transaction creation. You typically receive it from the SDK rather than constructing it manually.

liveID, err := surrealdb.Live(ctx, db, models.Table("persons"), false)
fmt.Println(liveID.String())

See Also