githubEdit

Byte

The byte type handles single byte values and byte slices for binary data storage.

Overview

Property
Value

Go Type

byte / *byte or []byte / *[]byte

Database Schema

int / option<int> (single) or bytes (slice)

CBOR Encoding

Direct

Sortable

Yes (single byte) / No (slice)

Single Byte

Definition

type Packet struct {
    som.Node

    Header    byte   // Required single byte
    TypeFlag  *byte  // Optional single byte
}

Schema

Generated SurrealDB schema with range validation:

Filter Operations

Single byte fields support base filter operations:

Nil Operations (Pointer Types Only)

Sorting

Byte Slice

Definition

Schema

Byte slices are stored as the SurrealDB bytes type:

Filter Operations

Base Operations

Base64 Encoding

Convert byte slice to base64 string for string operations:

Nil Operations (Pointer Types Only)

Creating Byte Values

Common Patterns

Filter by Header Value

Filter by Data Content

Base64 String Matching

Documents with Checksum

Complete Example

Filter Reference Table

Single Byte

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

Zero(bool)

Check if zero

Bool filter

Truth()

To boolean

Bool filter

IsNil()

Is null (ptr only)

Bool filter

IsNotNil()

Not null (ptr only)

Bool filter

Byte Slice

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

Zero(bool)

Check if empty

Bool filter

Truth()

To boolean

Bool filter

Base64Encode()

Convert to base64

String filter

IsNil()

Is null (ptr only)

Bool filter

IsNotNil()

Not null (ptr only)

Bool filter

Last updated