mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
refactor(customer): refactor customer db with storage utils and move trait to domain_models and impl to storage_model (#7538)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -179,6 +179,37 @@ impl<T: DatabaseStore> RouterStore<T> {
|
||||
.change_context(StorageError::DecryptionError)
|
||||
}
|
||||
|
||||
pub async fn find_optional_resource<D, R, M>(
|
||||
&self,
|
||||
state: &KeyManagerState,
|
||||
key_store: &MerchantKeyStore,
|
||||
execute_query_fut: R,
|
||||
) -> error_stack::Result<Option<D>, StorageError>
|
||||
where
|
||||
D: Debug + Sync + Conversion,
|
||||
R: futures::Future<
|
||||
Output = error_stack::Result<Option<M>, diesel_models::errors::DatabaseError>,
|
||||
> + Send,
|
||||
M: ReverseConversion<D>,
|
||||
{
|
||||
match execute_query_fut.await.map_err(|error| {
|
||||
let new_err = diesel_error_to_data_error(*error.current_context());
|
||||
error.change_context(new_err)
|
||||
})? {
|
||||
Some(resource) => Ok(Some(
|
||||
resource
|
||||
.convert(
|
||||
state,
|
||||
key_store.key.get_inner(),
|
||||
key_store.merchant_id.clone().into(),
|
||||
)
|
||||
.await
|
||||
.change_context(StorageError::DecryptionError)?,
|
||||
)),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn find_resources<D, R, M>(
|
||||
&self,
|
||||
state: &KeyManagerState,
|
||||
|
||||
Reference in New Issue
Block a user