Skip to content

API Reference

/

Values

UUID

The UUID struct wraps the UUID type of the github.com/gofrs/uuid package. The SDK encodes a UUID as CBOR tag 37, the tag that SurrealDB specifies for a UUID. A UUID can hold a UUID v4 or v7 value.

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

Source: pkg/models/uuid.go

type UUID struct {
    uuid.UUID
}

UUID embeds github.com/gofrs/uuid.UUID, so every method of uuid.UUID is available on it.

A string type that holds a UUID as text. The SDK encodes it as CBOR tag 9.

type UUIDString string

The SDK encodes a UUID as CBOR tag 37, which holds the UUID as 16 bytes. It encodes a UUIDString as CBOR tag 9, which holds the UUID as text.

Live query functions return a UUID, and a new session or transaction has a UUID as its ID. You usually get a UUID from the SDK instead of making one yourself.

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

Was this page helpful?

Last updated