TitoModel

Struct TitoModel 

Source
pub struct TitoModel<E: TitoEngine, T> {
    pub model: T,
    pub engine: E,
}

Fields§

§model: T§engine: E

Implementations§

Source§

impl<E: TitoEngine, T: TitoModelConstraints> TitoModel<E, T>

Source

pub fn relationships(&self) -> Vec<TitoRelationshipConfig>

Source

pub fn get_table(&self) -> String

Source

pub fn get_id_from_table(&self, key: String) -> String

Source

pub fn query_by_index( &self, index: impl Into<String>, ) -> IndexQueryBuilder<E, T>

Source

pub async fn tx<F, Fut, R, Err>(&self, f: F) -> Result<R, Err>
where F: FnOnce(E::Transaction) -> Fut + Send, Fut: Future<Output = Result<R, Err>> + Send, Err: From<TitoError> + Send + Sync + Debug, R: Send,

Source

pub async fn get_key( &self, key: &str, tx: &E::Transaction, ) -> Result<Value, TitoError>

Source

pub async fn delete( &self, key: String, tx: &E::Transaction, ) -> Result<bool, TitoError>

Source

pub fn to_paginated_items_with_cursor( &self, items: Vec<(String, Value)>, cursor: String, ) -> Result<TitoPaginated<T>, TitoError>

Source

pub fn to_paginated_items( &self, items: Vec<(String, Value)>, has_more: bool, ) -> Result<TitoPaginated<T>, TitoError>

Source

pub fn get_nested_values( &self, json: &Value, field_path: &str, ) -> Option<Vec<FieldValue>>

Source

pub async fn build( &self, payload: T, tx: &E::Transaction, ) -> Result<T, TitoError>

Source

pub async fn build_with_options( &self, payload: T, options: TitoOptions, tx: &E::Transaction, ) -> Result<T, TitoError>

Source

pub async fn find_by_id_tx( &self, id: &str, rels: Vec<String>, tx: &E::Transaction, ) -> Result<T, TitoError>

Source

pub async fn find_by_id( &self, id: &str, rels: Vec<String>, ) -> Result<T, TitoError>

Source

pub async fn scan( &self, payload: TitoScanPayload, tx: &E::Transaction, ) -> Result<(Vec<(String, Value)>, bool), TitoError>

Source

pub async fn find_by_ids_tx( &self, ids: Vec<String>, rels: Vec<String>, tx: &E::Transaction, ) -> Result<Vec<T>, TitoError>

Source

pub async fn find_by_ids_raw( &self, ids: Vec<String>, rels: Vec<String>, tx: &E::Transaction, ) -> Result<Vec<(String, Value)>, TitoError>

Source

pub async fn find_by_ids( &self, ids: Vec<String>, rels: Vec<String>, ) -> Result<Vec<T>, TitoError>

Source

pub async fn scan_reverse( &self, payload: TitoScanPayload, tx: &E::Transaction, ) -> Result<(Vec<(String, Value)>, bool), TitoError>

Source

pub async fn update( &self, payload: T, tx: &E::Transaction, ) -> Result<bool, TitoError>

Source

pub fn get_last_id(&self, key: String) -> Option<String>

Source

pub async fn update_with_options( &self, payload: T, options: TitoOptions, tx: &E::Transaction, ) -> Result<bool, TitoError>

Source

pub async fn lock_keys( &self, keys: Vec<String>, tx: &E::Transaction, ) -> Result<bool, TitoError>

Source

pub async fn batch_get( &self, keys: Vec<String>, max_retries: usize, initial_delay_ms: u64, tx: &E::Transaction, ) -> Result<Vec<(String, Value)>, TitoError>

Source

pub async fn delete_by_id_with_options( &self, raw_id: &str, options: TitoOptions, tx: &E::Transaction, ) -> Result<bool, TitoError>

Source

pub async fn delete_by_id( &self, raw_id: &str, tx: &E::Transaction, ) -> Result<bool, TitoError>

Source

pub async fn has_inbound_references( engine: &E, target_id: &str, tx: &E::Transaction, ) -> Result<bool, TitoError>

Source

pub async fn inbound_references( engine: &E, target_id: &str, limit: u32, tx: &E::Transaction, ) -> Result<Vec<String>, TitoError>

Source

pub async fn outbound_references( engine: &E, source_id: &str, limit: u32, tx: &E::Transaction, ) -> Result<Vec<String>, TitoError>

Source

pub async fn find( &self, payload: TitoFindPayload, ) -> Result<TitoPaginated<T>, TitoError>

Source

pub async fn add_field( &self, field_name: &str, field_value: Value, ) -> Result<(), TitoError>

Source

pub async fn remove_field(&self, field_name: &str) -> Result<(), TitoError>

Source

pub async fn find_all(&self) -> Result<TitoPaginated<T>, TitoError>

Source§

impl<E: TitoEngine, T: Default + Clone + Serialize + DeserializeOwned + Unpin + Send + Sync + TitoModelTrait> TitoModel<E, T>

Source

pub fn get_index_keys( &self, id: String, value: &T, json: &Value, ) -> Result<Vec<(String, Value)>, TitoError>

Source

pub async fn find_by_index_raw( &self, payload: TitoFindByIndexPayload, tx: &E::Transaction, ) -> Result<(Vec<(String, Value)>, bool), TitoError>

Source

pub async fn find_by_index_reverse_raw( &self, payload: TitoFindByIndexPayload, tx: &E::Transaction, ) -> Result<(Vec<(String, Value)>, bool), TitoError>

Source

pub async fn find_by_index_tx( &self, payload: TitoFindByIndexPayload, tx: &E::Transaction, ) -> Result<TitoPaginated<T>, TitoError>

Source

pub async fn find_by_index( &self, payload: TitoFindByIndexPayload, ) -> Result<TitoPaginated<T>, TitoError>

Source

pub async fn find_by_index_reverse_tx( &self, payload: TitoFindByIndexPayload, tx: &E::Transaction, ) -> Result<TitoPaginated<T>, TitoError>

Source

pub async fn find_by_index_reverse( &self, payload: TitoFindByIndexPayload, ) -> Result<TitoPaginated<T>, TitoError>

Source

pub async fn find_one_by_index_tx( &self, payload: TitoFindOneByIndexPayload, tx: &E::Transaction, ) -> Result<T, TitoError>

Source

pub async fn find_one_by_index( &self, payload: TitoFindOneByIndexPayload, ) -> Result<T, TitoError>

Source

pub async fn reindex(&self) -> Result<(), TitoError>

Source§

impl<E: TitoEngine, T: Default + Clone + Serialize + DeserializeOwned + Unpin + Send + Sync + TitoModelTrait> TitoModel<E, T>

Source

pub fn stitch_relationship( &self, item: &mut Value, rel_map: &HashMap<String, Value>, config: &TitoRelationshipConfig, )

Public entry point for stitching a relationship into a JSON Value.

Source

pub fn get_relationship_data( &self, items: &Vec<(String, Value)>, rels_config: &[TitoRelationshipConfig], rels: &Vec<String>, ) -> Vec<(TitoRelationshipConfig, String)>

Gathers all relationship keys that need to be fetched from a list of items.

Source

pub async fn fetch_and_stitch_relationships( &self, items: Vec<(String, Value)>, rels: Vec<String>, tx: &E::Transaction, ) -> Result<Vec<(String, Value)>, TitoError>

Fetches and stitches all requested relationships for a vector of items.

Source

pub fn extract_relationship(&self, input: &str) -> Option<String>

A helper function to extract a relationship string.

Trait Implementations§

Source§

impl<E: Clone + TitoEngine, T: Clone> Clone for TitoModel<E, T>

Source§

fn clone(&self) -> TitoModel<E, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<E, T> Freeze for TitoModel<E, T>
where T: Freeze, E: Freeze,

§

impl<E, T> RefUnwindSafe for TitoModel<E, T>

§

impl<E, T> Send for TitoModel<E, T>
where T: Send,

§

impl<E, T> Sync for TitoModel<E, T>
where T: Sync,

§

impl<E, T> Unpin for TitoModel<E, T>
where T: Unpin, E: Unpin,

§

impl<E, T> UnwindSafe for TitoModel<E, T>
where T: UnwindSafe, E: 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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,