Skip to main content

RelTable

Struct RelTable 

Source
pub struct RelTable<'a, B>
where B: StorageBackend,
{ /* private fields */ }
Expand description

One table of a RelationalDb. Every method runs (and commits) its own transaction; use RelationalDb::write_tx or Db::write_tx to group several operations atomically.

Implementations§

Source§

impl<'a, B> RelTable<'a, B>
where B: StorageBackend,

Source

pub fn schema(&self) -> &TableSchema

The schema this handle was created with (for a handle from RelationalDb::table_named, the definition at that time — operations always use the current one).

Source

pub fn insert( &self, values: BTreeMap<String, PropValue>, ) -> Result<PropValue, BknError>

Inserts a new row. For an auto-increment schema, values should not include the primary-key column (it’s allocated here); the generated PK is returned. For a non-auto-increment schema, values must include the primary-key column — use RelTable::insert_with_pk instead if the PK comes from elsewhere (e.g. an existing NodeId). Fails with BknError::DuplicateKey if the pk is taken.

Source

pub fn insert_bulk( &self, rows: impl IntoIterator<Item = BTreeMap<String, PropValue>>, ) -> Result<Vec<PropValue>, BknError>

Inserts multiple rows in a single transaction, reserving PKs in one counter update if auto-increment is enabled.

Source

pub fn insert_with_pk( &self, pk: PropValue, values: BTreeMap<String, PropValue>, ) -> Result<(), BknError>

Inserts a row under an explicit, caller-supplied PK — the mechanism for linking a relational row to an existing id from elsewhere (e.g. a graph crate::graph::NodeId). Rejected on an auto-increment schema, where PKs must come from RelTable::insert instead.

Source

pub fn insert_with_pk_bulk( &self, rows: impl IntoIterator<Item = (PropValue, BTreeMap<String, PropValue>)>, ) -> Result<(), BknError>

Inserts multiple rows with caller-supplied PKs in a single transaction.

Source

pub fn upsert( &self, values: BTreeMap<String, PropValue>, ) -> Result<PropValue, BknError>

Like RelTable::insert, but replaces an existing row with the same pk instead of failing. On an auto-increment schema, a row without a pk gets a fresh one and a row with a pk is upserted under it.

Source

pub fn upsert_bulk( &self, rows: impl IntoIterator<Item = BTreeMap<String, PropValue>>, ) -> Result<Vec<PropValue>, BknError>

Source

pub fn upsert_with_pk( &self, pk: PropValue, values: BTreeMap<String, PropValue>, ) -> Result<(), BknError>

Inserts the row, or replaces the existing row with the same PK (keeping every secondary index consistent). Works on any schema, including auto-increment ones.

Source

pub fn upsert_with_pk_bulk( &self, rows: impl IntoIterator<Item = (PropValue, BTreeMap<String, PropValue>)>, ) -> Result<(), BknError>

Source

pub fn get(&self, pk: &PropValue) -> Result<Option<Row>, BknError>

Source

pub fn select(&self) -> SelectQuery<'a, B>

Source

pub fn update(&self) -> UpdateQuery<'a, B>

Source

pub fn delete(&self) -> DeleteQuery<'a, B>

Source

pub fn select_prefix( &self, column: &str, prefix: &str, ) -> Result<Vec<Row>, BknError>

Rows whose column string value starts with prefix, using that column’s secondary index if available, falling back to a full scan.

Trait Implementations§

Source§

impl<'a, B> Clone for RelTable<'a, B>
where B: StorageBackend,

Source§

fn clone(&self) -> RelTable<'a, B>

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§

§

impl<'a, B> Freeze for RelTable<'a, B>
where &'a RelationalDb<B>: Freeze,

§

impl<'a, B> RefUnwindSafe for RelTable<'a, B>

§

impl<'a, B> Send for RelTable<'a, B>
where &'a RelationalDb<B>: Send,

§

impl<'a, B> Sync for RelTable<'a, B>
where &'a RelationalDb<B>: Sync,

§

impl<'a, B> Unpin for RelTable<'a, B>
where &'a RelationalDb<B>: Unpin,

§

impl<'a, B> UnsafeUnpin for RelTable<'a, B>
where &'a RelationalDb<B>: UnsafeUnpin,

§

impl<'a, B> UnwindSafe for RelTable<'a, B>
where &'a RelationalDb<B>: UnwindSafe,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.