Expand description
Key encoding for Kit indexes, guards, and primary keys.
§Format
Each encoded key is a colon-separated (:) string of typed components.
A component is one of:
i:<value>– a signed integer value (mirrors a TypeScriptbigint).s:<text>– a string value. Colons and backslashes in<text>are escaped as\:and\\respectively.n:null– an explicit SQLNULLmarker.
encode_pk joins components directly with : and is suitable for use as
a primary-key literal inside other keys. encode_unique_key prefixes the
components with uq:<version>:<constraint_name>: so the resulting string
is globally unique per constraint. encode_row_guard_key prefixes an
already-encoded primary key with rg:<table_name>:.
This matches the TypeScript kit (src/keys.ts) byte-for-byte so the three
languages produce identical guard and unique-key entries. In particular the
typed i:/s: prefixes guarantee that the integer 1 and the text "1"
never collide.
Enums§
- KeyComponent
- A single typed key component.
Constants§
- KIT_
KEY_ VERSION - Stable on-disk format version embedded in unique-key encodings.
Functions§
- decode_
pk - Decode an encoded primary key into its typed components.
- encode_
component - Encode a single typed component.
- encode_
pk - Encode a primary key value.
- encode_
row_ guard_ key - Encode a row-guard key for optimistic foreign-key checks.
- encode_
unique_ key - Encode a unique-constraint key.