pub struct TitoModel<E: TitoEngine, T> {
pub model: T,
pub engine: E,
}Fields§
§model: T§engine: EImplementations§
Source§impl<E: TitoEngine, T: TitoModelConstraints> TitoModel<E, T>
impl<E: TitoEngine, T: TitoModelConstraints> TitoModel<E, T>
pub fn relationships(&self) -> Vec<TitoRelationshipConfig> ⓘ
pub fn get_table(&self) -> String
pub fn get_id_from_table(&self, key: String) -> String
pub fn query_by_index( &self, index: impl Into<String>, ) -> IndexQueryBuilder<E, T>
pub async fn tx<F, Fut, R, Err>(&self, f: F) -> Result<R, Err>
pub async fn get_key( &self, key: &str, tx: &E::Transaction, ) -> Result<Value, TitoError>
pub async fn delete( &self, key: String, tx: &E::Transaction, ) -> Result<bool, TitoError>
pub fn to_paginated_items_with_cursor( &self, items: Vec<(String, Value)>, cursor: String, ) -> Result<TitoPaginated<T>, TitoError>
pub fn to_paginated_items( &self, items: Vec<(String, Value)>, has_more: bool, ) -> Result<TitoPaginated<T>, TitoError>
pub fn get_nested_values( &self, json: &Value, field_path: &str, ) -> Option<Vec<FieldValue>>
pub async fn build(
&self,
payload: T,
tx: &E::Transaction,
) -> Result<T, TitoError>where
T: DeserializeOwned,
pub async fn build_with_options(
&self,
payload: T,
options: TitoOptions,
tx: &E::Transaction,
) -> Result<T, TitoError>where
T: DeserializeOwned,
pub async fn find_by_id_tx(
&self,
id: &str,
rels: Vec<String>,
tx: &E::Transaction,
) -> Result<T, TitoError>where
T: DeserializeOwned,
pub async fn find_by_id(
&self,
id: &str,
rels: Vec<String>,
) -> Result<T, TitoError>where
T: DeserializeOwned,
pub async fn scan(
&self,
payload: TitoScanPayload,
tx: &E::Transaction,
) -> Result<(Vec<(String, Value)>, bool), TitoError>where
T: DeserializeOwned,
pub async fn find_by_ids_tx(
&self,
ids: Vec<String>,
rels: Vec<String>,
tx: &E::Transaction,
) -> Result<Vec<T>, TitoError>where
T: DeserializeOwned,
pub async fn find_by_ids_raw(
&self,
ids: Vec<String>,
rels: Vec<String>,
tx: &E::Transaction,
) -> Result<Vec<(String, Value)>, TitoError>where
T: DeserializeOwned,
pub async fn find_by_ids(
&self,
ids: Vec<String>,
rels: Vec<String>,
) -> Result<Vec<T>, TitoError>where
T: DeserializeOwned,
pub async fn scan_reverse(
&self,
payload: TitoScanPayload,
tx: &E::Transaction,
) -> Result<(Vec<(String, Value)>, bool), TitoError>where
T: DeserializeOwned,
pub async fn update(
&self,
payload: T,
tx: &E::Transaction,
) -> Result<bool, TitoError>where
T: DeserializeOwned,
pub fn get_last_id(&self, key: String) -> Option<String>
pub async fn update_with_options(
&self,
payload: T,
options: TitoOptions,
tx: &E::Transaction,
) -> Result<bool, TitoError>where
T: DeserializeOwned,
pub async fn lock_keys( &self, keys: Vec<String>, tx: &E::Transaction, ) -> Result<bool, TitoError>
pub async fn batch_get( &self, keys: Vec<String>, max_retries: usize, initial_delay_ms: u64, tx: &E::Transaction, ) -> Result<Vec<(String, Value)>, TitoError>
pub async fn delete_by_id_with_options( &self, raw_id: &str, options: TitoOptions, tx: &E::Transaction, ) -> Result<bool, TitoError>
pub async fn delete_by_id( &self, raw_id: &str, tx: &E::Transaction, ) -> Result<bool, TitoError>
pub async fn has_inbound_references( engine: &E, target_id: &str, tx: &E::Transaction, ) -> Result<bool, TitoError>
pub async fn inbound_references( engine: &E, target_id: &str, limit: u32, tx: &E::Transaction, ) -> Result<Vec<String>, TitoError>
pub async fn outbound_references( engine: &E, source_id: &str, limit: u32, tx: &E::Transaction, ) -> Result<Vec<String>, TitoError>
pub async fn find(
&self,
payload: TitoFindPayload,
) -> Result<TitoPaginated<T>, TitoError>where
T: DeserializeOwned,
pub async fn add_field( &self, field_name: &str, field_value: Value, ) -> Result<(), TitoError>
pub async fn remove_field(&self, field_name: &str) -> Result<(), TitoError>
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>
impl<E: TitoEngine, T: Default + Clone + Serialize + DeserializeOwned + Unpin + Send + Sync + TitoModelTrait> TitoModel<E, T>
pub fn get_index_keys( &self, id: String, value: &T, json: &Value, ) -> Result<Vec<(String, Value)>, TitoError>
pub async fn find_by_index_raw(
&self,
payload: TitoFindByIndexPayload,
tx: &E::Transaction,
) -> Result<(Vec<(String, Value)>, bool), TitoError>where
T: DeserializeOwned,
pub async fn find_by_index_reverse_raw(
&self,
payload: TitoFindByIndexPayload,
tx: &E::Transaction,
) -> Result<(Vec<(String, Value)>, bool), TitoError>where
T: DeserializeOwned,
pub async fn find_by_index_tx(
&self,
payload: TitoFindByIndexPayload,
tx: &E::Transaction,
) -> Result<TitoPaginated<T>, TitoError>where
T: DeserializeOwned,
pub async fn find_by_index(
&self,
payload: TitoFindByIndexPayload,
) -> Result<TitoPaginated<T>, TitoError>where
T: DeserializeOwned,
pub async fn find_by_index_reverse_tx(
&self,
payload: TitoFindByIndexPayload,
tx: &E::Transaction,
) -> Result<TitoPaginated<T>, TitoError>where
T: DeserializeOwned,
pub async fn find_by_index_reverse(
&self,
payload: TitoFindByIndexPayload,
) -> Result<TitoPaginated<T>, TitoError>where
T: DeserializeOwned,
pub async fn find_one_by_index_tx(
&self,
payload: TitoFindOneByIndexPayload,
tx: &E::Transaction,
) -> Result<T, TitoError>where
T: DeserializeOwned,
pub async fn find_one_by_index(
&self,
payload: TitoFindOneByIndexPayload,
) -> Result<T, TitoError>where
T: DeserializeOwned,
pub async fn reindex(&self) -> Result<(), TitoError>
Source§impl<E: TitoEngine, T: Default + Clone + Serialize + DeserializeOwned + Unpin + Send + Sync + TitoModelTrait> TitoModel<E, T>
impl<E: TitoEngine, T: Default + Clone + Serialize + DeserializeOwned + Unpin + Send + Sync + TitoModelTrait> TitoModel<E, T>
Sourcepub fn stitch_relationship(
&self,
item: &mut Value,
rel_map: &HashMap<String, Value>,
config: &TitoRelationshipConfig,
)
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.
Sourcepub fn get_relationship_data(
&self,
items: &Vec<(String, Value)>,
rels_config: &[TitoRelationshipConfig],
rels: &Vec<String>,
) -> Vec<(TitoRelationshipConfig, String)>
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.
Sourcepub async fn fetch_and_stitch_relationships(
&self,
items: Vec<(String, Value)>,
rels: Vec<String>,
tx: &E::Transaction,
) -> Result<Vec<(String, Value)>, TitoError>
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.
Sourcepub fn extract_relationship(&self, input: &str) -> Option<String>
pub fn extract_relationship(&self, input: &str) -> Option<String>
A helper function to extract a relationship string.
Trait Implementations§
Auto Trait Implementations§
impl<E, T> Freeze for TitoModel<E, T>
impl<E, T> RefUnwindSafe for TitoModel<E, T>where
T: RefUnwindSafe,
E: RefUnwindSafe,
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>
impl<E, T> UnwindSafe for TitoModel<E, T>where
T: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request