Skip to main content

RelTable

Struct RelTable 

Source
pub struct RelTable { /* private fields */ }
Expand description

RelTable — the main relational interface for one entity type. Thin, cheap to clone (Arc internally).

Implementations§

Source§

impl RelTable

Source

pub fn new(db: Arc<DonaDb>, config: RelTableConfig) -> Self

Source

pub fn schema(&self) -> &Schema

Source

pub fn domain_id(&self) -> DomainId

Source

pub fn put_record( &self, record: &Record, block_height: BlockHeight, entropy: &[u8], ) -> Result<(), RelError>

Write a typed record at block_height. Validates field types, encodes key + value, maintains all secondary indexes. Everything goes into a single WriteBatch — atomic across primary + all indexes.

Source

pub fn put_records( &self, records: &[Record], block_height: BlockHeight, entropy: &[u8], ) -> Result<(), RelError>

Batch put for multiple records — single WriteBatch for all of them. More efficient than calling put_record() N times when writing multiple records at the same block height.

Source

pub fn get_record( &self, key_values: &[FieldValue], ) -> Result<Option<Record>, RelError>

Get a record by its primary key field values (latest version).

Source

pub fn get_record_at( &self, key_values: &[FieldValue], block_height: BlockHeight, ) -> Result<Option<Record>, RelError>

Get a record at a specific block height (point-in-time read).

Source

pub fn scan_where( &self, predicates: &[Predicate], ) -> Result<Vec<Record>, RelError>

Filter records by predicates. Uses secondary index when available for Eq predicates. All predicates must be satisfied (implicit AND).

Source

pub fn scan_range( &self, start_key: &[FieldValue], end_key: &[FieldValue], ) -> Result<Vec<Record>, RelError>

Range scan by primary key bounds. Returns records ordered by primary key.

Source

pub fn scan_prefix_raw(&self, prefix: &[u8]) -> Result<Vec<Record>, RelError>

Prefix scan on primary key bytes. Returns all records whose key starts with prefix.

Source

pub fn count_where(&self, predicates: &[Predicate]) -> Result<usize, RelError>

Count records matching predicates without materialising them.

Source

pub fn scan_all_raw(&self) -> Result<Vec<Record>, RelError>

Scan all records in this table (no filter).

Source

pub fn follow_ref( &self, record: &Record, ref_field: &str, target: &RelTable, ) -> Result<Option<Record>, RelError>

Follow a foreign key reference: read ref_field from this record, then look it up as a primary key in target RelTable.

Example: token_transfers.follow_ref(record, “holder_address”, &accounts_table) → returns the Account record for the holder

Source

pub fn delete_record( &self, key_values: &[FieldValue], block_height: BlockHeight, entropy: &[u8], ) -> Result<(), RelError>

Tombstone a record: write an empty value to mark it deleted. DonaDB never physically removes data — this is the correct deletion model. Index entries are also tombstoned so they do not appear in future scans.

Trait Implementations§

Source§

impl Clone for RelTable

Source§

fn clone(&self) -> RelTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.