Expand description
Record ID — the universal document/record identifier for SochDB’s multi-model layer.
A RecordId combines a table name with a unique identifier within that table,
modeled after SurrealDB’s thing concept (table:id).
§Binary Key Encoding
[table_id: u32 BE][id_bytes: variable]table_idis a 4-byte big-endian table hash (FNV-1a) for sort-ordered prefix scans.id_bytesis the raw identifier — either a big-endian u64 for integer IDs, or UTF-8 bytes for string IDs.
Big-endian encoding ensures lexicographic byte ordering matches numeric ordering, enabling efficient range scans on the underlying KV store.
§Display Format
table:id — e.g. person:1, post:abc, user:⟨uuid⟩
§Examples
use sochdb_core::record_id::RecordId;
// Integer ID
let rid = RecordId::new("person", 42u64);
assert_eq!(rid.table(), "person");
assert_eq!(rid.to_string(), "person:42");
// String ID
let rid = RecordId::from_string("post", "hello-world");
assert_eq!(rid.to_string(), "post:hello-world");
// Round-trip through binary key
let key = rid.to_key();
let decoded = RecordId::from_key_with_table(&key, "post").unwrap();
assert_eq!(rid, decoded);Structs§
- Record
Id - A
RecordIdis a(table, id)pair that uniquely identifies a record across SochDB’s multi-model storage.
Enums§
- IdValue
- The identifier part of a RecordId.