githubEdit

UUID

The UUID type handles universally unique identifiers using github.com/google/uuid with binary CBOR encoding.

Overview

Property
Value

Go Type

uuid.UUID / *uuid.UUID

Database Schema

uuid / option<uuid>

CBOR Encoding

Tag 37 with 16-byte binary

Sortable

Yes

CBOR Encoding

UUID values are encoded with CBOR Tag 37 as binary data:

Tag 37: <16 bytes binary UUID>

This provides:

  • Efficient binary storage

  • Proper round-tripping with SurrealDB

  • Standard UUID representation

Definition

import "github.com/google/uuid"

type Document struct {
    som.Node

    ExternalID  uuid.UUID   // Required
    TrackingID  uuid.UUID   // Required
    ParentID    *uuid.UUID  // Optional
}

Schema

Generated SurrealDB schema:

Creating UUIDs

Filter Operations

Equality Operations

Set Membership

Comparison Operations

UUIDs can be compared lexicographically:

Nil Operations (Pointer Types Only)

Zero Value Check

Sorting

Common Patterns

Find by External ID

Find Children by Parent

Find Root Documents (No Parent)

Bulk Lookup

Complete Example

Filter Reference Table

Operation
Description
Returns

Equal(val)

Exact match

Bool filter

NotEqual(val)

Not equal

Bool filter

In(vals...)

Value in set

Bool filter

NotIn(vals...)

Value not in set

Bool filter

LessThan(val)

Lexicographic <

Bool filter

LessThanEqual(val)

Lexicographic <=

Bool filter

GreaterThan(val)

Lexicographic >

Bool filter

GreaterThanEqual(val)

Lexicographic >=

Bool filter

Zero(bool)

Check nil UUID

Bool filter

Truth()

To boolean

Bool filter

IsNil()

Is null (ptr)

Bool filter

IsNotNil()

Not null (ptr)

Bool filter

Last updated