text stringlengths 70 351k | source stringclasses 4
values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generics.rs | crate: diesel_models
use std::fmt::Debug;
use diesel::{
associations::HasTable,
debug_query,
dsl::{Find, Limit},
helper_types::{Filter, IntoBoxed},
insertable::CanInsertInSingleQuery,
pg::{Pg, PgConnection},
query_builder::{
AsChangeset, AsQuery, DeleteStatement, InsertStatement, IntoUpdateTarget, QueryFragment,
QueryId, UpdateStatement,
},
query_dsl::{
methods::{BoxedDsl, FilterDsl, FindDsl, LimitDsl, OffsetDsl, OrderDsl},
LoadQuery, RunQueryDsl,
},
result::Error as DieselError,
Expression, Insertable, QueryDsl, QuerySource, Table,
};
use error_stack::{report, ResultExt};
use router_env::logger;
use crate::{errors, PgPooledConn, StorageResult};
async fn generic_find_by_id_core<T, Pk, R>(conn: &PgPooledConn, id: Pk) -> StorageResult<R>
where
T: FindDsl<Pk> + HasTable<Table = T> + LimitDsl + Table + 'static,
Find<T, Pk>: LimitDsl + QueryFragment<Pg> + RunQueryDsl<PgConnection> + Send + 'static,
Limit<Find<T, Pk>>: LoadQuery<'static, PgConnection, R>,
Pk: Clone + Debug,
R: Send + 'static,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generics.rs | crate: diesel_models
use std::fmt::Debug;
use diesel::{
associations::HasTable,
debug_query,
dsl::{Find, Limit},
helper_types::{Filter, IntoBoxed},
insertable::CanInsertInSingleQuery,
pg::{Pg, PgConnection},
query_builder::{
AsChangeset, AsQuery, DeleteStatement, InsertStatement, IntoUpdateTarget, QueryFragment,
QueryId, UpdateStatement,
},
query_dsl::{
methods::{BoxedDsl, FilterDsl, FindDsl, LimitDsl, OffsetDsl, OrderDsl},
LoadQuery, RunQueryDsl,
},
result::Error as DieselError,
Expression, Insertable, QueryDsl, QuerySource, Table,
};
use router_env::logger;
use crate::{errors, PgPooledConn, StorageResult};
pub async fn generic_update<T, V, P>(
conn: &PgPooledConn,
predicate: P,
values: V,
) -> StorageResult<usize>
where
T: FilterDsl<P> + HasTable<Table = T> + Table + 'static,
V: AsChangeset<Target = <Filter<T, P> as HasTable>::Table> + Debug,
Filter<T, P>: IntoUpdateTarget,
UpdateStatement<
<Filter<T, P> as HasTable>::Table,
<Filter<T, P> as IntoUpdateTarget>::WhereClause,
<V as AsChangeset>::Changeset,
>: AsQuery + QueryFragment<Pg> + QueryId + Send + 'static,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generics.rs | crate: diesel_models
use std::fmt::Debug;
use router_env::logger;
use crate::{errors, PgPooledConn, StorageResult};
pub async fn track_database_call<T, Fut, U>(future: Fut, operation: DatabaseOperation) -> U
where
Fut: std::future::Future<Output = U>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use time::PrimitiveDateTime;
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_processes_to_clean(
conn: &PgPooledConn,
time_lower_limit: PrimitiveDateTime,
time_upper_limit: PrimitiveDateTime,
runner: &str,
limit: usize,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
process: ProcessTrackerUpdate,
) -> StorageResult<Self> {
{
errors::DatabaseError::NoFieldsToUpdate => Ok(self),<|fim_suffix|>
<|fim_middle|>
_ => Err(error),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use time::PrimitiveDateTime;
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn reinitialize_limbo_processes(
conn: &PgPooledConn,
ids: Vec<String>,
schedule_time: PrimitiveDateTime,
) -> StorageResult<usize> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use time::PrimitiveDateTime;
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_processes_by_time_status(
conn: &PgPooledConn,
time_lower_limit: PrimitiveDateTime,
time_upper_limit: PrimitiveDateTime,
status: enums::ProcessTrackerStatus,
limit: Option<i64>,
version: enums::ApiVersion,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_process_by_id(conn: &PgPooledConn, id: &str) -> StorageResult<Option<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_process_status_by_ids(
conn: &PgPooledConn,
task_ids: Vec<String>,
task_update: ProcessTrackerUpdate,
) -> StorageResult<usize> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
process: ProcessTrackerUpdate,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/process_tracker.rs | crate: diesel_models
use super::generics;
use crate::{
enums, errors,
process_tracker::{
ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate, ProcessTrackerUpdateInternal,
},
schema::process_tracker::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert_process(self, conn: &PgPooledConn) -> StorageResult<ProcessTracker> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn list_profile_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn update_by_profile_id(
self,
conn: &PgPooledConn,
business_profile: ProfileUpdateInternal,
) -> StorageResult<Self> {
{
errors::DatabaseError::NoFieldsToUpdate => Ok(self),<|fim_suffix|>
<|fim_middle|>
_ => Err(error),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn delete_by_profile_id_merchant_id(
conn: &PgPooledConn,
profile_id: &common_utils::id_type::ProfileId,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<bool> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn list_profile_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Vec<Self>> {
generics::generic_filter::<
<Self as HasTable>::Table,
_,
<<Self as HasTable>::Table as Table>::PrimaryKey,
_,
>(
conn,
dsl::merchant_id.eq(merchant_id.to_owned()),
None,
None,
None,
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn find_by_profile_name_merchant_id(
conn: &PgPooledConn,
profile_name: &str,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_id_profile_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
profile_id: &common_utils::id_type::ProfileId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn find_by_profile_id(
conn: &PgPooledConn,
profile_id: &common_utils::id_type::ProfileId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn update_by_profile_id(
self,
conn: &PgPooledConn,
business_profile: ProfileUpdateInternal,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/business_profile.rs | crate: diesel_models
use super::generics;
use crate::schema::business_profile::dsl::{self, profile_id as dsl_identifier};
use crate::schema_v2::business_profile::dsl::{self, id as dsl_identifier};
use crate::{
business_profile::{Profile, ProfileNew, ProfileUpdateInternal},
errors, PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Profile> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use common_utils::{errors, ext_traits::ValueExt, link_utils::GenericLinkStatus};
use error_stack::{report, Report, ResultExt};
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
fn try_from(db_val: GenericLink) -> Result<Self, Self::Error> {
{
common_enums::GenericLinkType::PayoutLink => {
let link_data = db_val.link_data.parse_value("PayoutLinkData")?;
let link_status = match db_val.link_status {
GenericLinkStatus::PayoutLink(status) => Ok(status),
_ => Err(report!(errors::ParsingError::EnumParseFailure(
"GenericLinkStatus"
)))
.attach_printable_lazy(|| {
format!("Invalid status for PayoutLink - {:?}", db_val.link_status)
}),
}?;
(link_data, link_status)
}<|fim_suffix|>
<|fim_middle|>
_ => Err(report!(errors::ParsingError::UnknownError)).attach_printable_lazy(|| {
format!("Invalid link_type for PayoutLink - {}", db_val.link_type)
})?,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use common_utils::{errors, ext_traits::ValueExt, link_utils::GenericLinkStatus};
use error_stack::{report, Report, ResultExt};
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
fn try_from(db_val: GenericLink) -> Result<Self, Self::Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use common_utils::{errors, ext_traits::ValueExt, link_utils::GenericLinkStatus};
use error_stack::{report, Report, ResultExt};
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
fn try_from(db_val: GenericLink) -> Result<Self, Self::Error> {
{
GenericLinkStatus::PayoutLink(status) => Ok(status),<|fim_suffix|>
<|fim_middle|>
_ => Err(report!(errors::ParsingError::EnumParseFailure(
"GenericLinkStatus"
)))
.attach_printable_lazy(|| {
format!("Invalid status for PayoutLink - {:?}", db_val.link_status)
}),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use error_stack::{report, Report, ResultExt};
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_payout_link(
self,
conn: &PgPooledConn,
payout_link_update: PayoutLinkUpdate,
) -> StorageResult<Self> {
{
db_errors::DatabaseError::NoFieldsToUpdate => Ok(self),<|fim_suffix|>
<|fim_middle|>
_ => Err(error),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use error_stack::{report, Report, ResultExt};
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_payout_link(
self,
conn: &PgPooledConn,
payout_link_update: PayoutLinkUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_payout_link_by_link_id(
conn: &PgPooledConn,
link_id: &str,
) -> StorageResult<PayoutLink> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_pm_collect_link_by_link_id(
conn: &PgPooledConn,
link_id: &str,
) -> StorageResult<PaymentMethodCollectLink> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::link_id.eq(link_id.to_owned()),
)
.await
.and_then(|res: Self| {
PaymentMethodCollectLink::try_from(res)
.change_context(db_errors::DatabaseError::Others)
.attach_printable("failed to parse payment method collect link data from DB")
})
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_generic_link_by_link_id(
conn: &PgPooledConn,
link_id: &str,
) -> StorageResult<GenericLinkState> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert_payout_link(self, conn: &PgPooledConn) -> StorageResult<PayoutLink> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert_pm_collect_link(
self,
conn: &PgPooledConn,
) -> StorageResult<PaymentMethodCollectLink> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/generic_link.rs | crate: diesel_models
use super::generics;
use crate::{
errors as db_errors,
generic_link::{
GenericLink, GenericLinkData, GenericLinkNew, GenericLinkState, GenericLinkUpdateInternal,
PaymentMethodCollectLink, PayoutLink, PayoutLinkUpdate,
},
schema::generic_link::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<GenericLinkState> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/api_keys.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_by_merchant_id_key_id(
conn: &PgPooledConn,
merchant_id: common_utils::id_type::MerchantId,
key_id: common_utils::id_type::ApiKeyId,
api_key_update: ApiKeyUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/api_keys.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_optional_by_hashed_api_key(
conn: &PgPooledConn,
hashed_api_key: HashedApiKey,
) -> StorageResult<Option<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/api_keys.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
limit: Option<i64>,
offset: Option<i64>,
) -> StorageResult<Vec<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/api_keys.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_optional_by_hashed_api_key(
conn: &PgPooledConn,
hashed_api_key: HashedApiKey,
) -> StorageResult<Option<Self>> {
generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(
conn,
dsl::hashed_api_key.eq(hashed_api_key),
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/api_keys.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_optional_by_merchant_id_key_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
key_id: &common_utils::id_type::ApiKeyId,
) -> StorageResult<Option<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/api_keys.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
pub async fn revoke_by_merchant_id_key_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
key_id: &common_utils::id_type::ApiKeyId,
) -> StorageResult<bool> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/api_keys.rs | crate: diesel_models
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<ApiKey> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::errors;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn update_by_customer_id_merchant_id(
conn: &PgPooledConn,
customer_id: id_type::CustomerId,
merchant_id: id_type::MerchantId,
customer: CustomerUpdateInternal,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::schema::customers::dsl;
use crate::schema_v2::customers::dsl;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_reference_id_merchant_id(
conn: &PgPooledConn,
merchant_reference_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn find_by_customer_id_merchant_id(
conn: &PgPooledConn,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::schema::customers::dsl;
use crate::schema_v2::customers::dsl;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_reference_id_merchant_id(
conn: &PgPooledConn,
merchant_reference_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::merchant_reference_id.eq(merchant_reference_id.to_owned())),
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::schema::customers::dsl;
use crate::schema_v2::customers::dsl;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn delete_by_customer_id_merchant_id(
conn: &PgPooledConn,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
) -> StorageResult<bool> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn find_optional_by_customer_id_merchant_id(
conn: &PgPooledConn,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
) -> StorageResult<Option<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::schema::customers::dsl;
use crate::schema_v2::customers::dsl;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn find_optional_by_merchant_id_merchant_reference_id(
conn: &PgPooledConn,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
) -> StorageResult<Option<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::schema::customers::dsl;
use crate::schema_v2::customers::dsl;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn list_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &id_type::MerchantId,
constraints: CustomerListConstraints,
) -> StorageResult<Vec<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn find_by_global_id(
conn: &PgPooledConn,
id: &id_type::GlobalCustomerId,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::errors;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn update_by_id(
conn: &PgPooledConn,
id: id_type::GlobalCustomerId,
customer: CustomerUpdateInternal,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/customers.rs | crate: diesel_models
use super::generics;
use crate::{
customers::{Customer, CustomerNew, CustomerUpdateInternal},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Customer> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/gsm.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use error_stack::report;
use crate::{
errors, gsm::*, query::generics, schema::gateway_status_map::dsl, PgPooledConn, StorageResult,
};
pub async fn update(
conn: &PgPooledConn,
connector: String,
flow: String,
sub_flow: String,
code: String,
message: String,
gsm: GatewayStatusMappingUpdate,
) -> StorageResult<Self> {
generics::generic_update_with_results::<
<Self as HasTable>::Table,
GatewayStatusMapperUpdateInternal,
_,
_,
>(
conn,
dsl::connector
.eq(connector)
.and(dsl::flow.eq(flow))
.and(dsl::sub_flow.eq(sub_flow))
.and(dsl::code.eq(code))
.and(dsl::message.eq(message)),
gsm.into(),
)
.await?
.first()
.cloned()
.ok_or_else(|| {
report!(errors::DatabaseError::NotFound)
.attach_printable("Error while updating gsm entry")
})
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/gsm.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use error_stack::report;
use crate::{
errors, gsm::*, query::generics, schema::gateway_status_map::dsl, PgPooledConn, StorageResult,
};
pub async fn update(
conn: &PgPooledConn,
connector: String,
flow: String,
sub_flow: String,
code: String,
message: String,
gsm: GatewayStatusMappingUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/gsm.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
errors, gsm::*, query::generics, schema::gateway_status_map::dsl, PgPooledConn, StorageResult,
};
pub async fn find(
conn: &PgPooledConn,
connector: String,
flow: String,
sub_flow: String,
code: String,
message: String,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/gsm.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
errors, gsm::*, query::generics, schema::gateway_status_map::dsl, PgPooledConn, StorageResult,
};
pub async fn delete(
conn: &PgPooledConn,
connector: String,
flow: String,
sub_flow: String,
code: String,
message: String,
) -> StorageResult<bool> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/gsm.rs | crate: diesel_models
use crate::{
errors, gsm::*, query::generics, schema::gateway_status_map::dsl, PgPooledConn, StorageResult,
};
pub async fn retrieve_decision(
conn: &PgPooledConn,
connector: String,
flow: String,
sub_flow: String,
code: String,
message: String,
) -> StorageResult<String> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/gsm.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
errors, gsm::*, query::generics, schema::gateway_status_map::dsl, PgPooledConn, StorageResult,
};
pub async fn find(
conn: &PgPooledConn,
connector: String,
flow: String,
sub_flow: String,
code: String,
message: String,
) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::connector
.eq(connector)
.and(dsl::flow.eq(flow))
.and(dsl::sub_flow.eq(sub_flow))
.and(dsl::code.eq(code))
.and(dsl::message.eq(message)),
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/gsm.rs | crate: diesel_models
use crate::{
errors, gsm::*, query::generics, schema::gateway_status_map::dsl, PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<GatewayStatusMap> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/connector_response.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use router_env::{instrument, logger, tracing};
use super::generics;
use crate::{
connector_response::{
ConnectorResponse, ConnectorResponseNew, ConnectorResponseUpdate,
ConnectorResponseUpdateInternal,
},
errors,
payment_attempt::{PaymentAttempt, PaymentAttemptUpdate, PaymentAttemptUpdateInternal},
schema::{connector_response::dsl, payment_attempt::dsl as pa_dsl},
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
connector_response: ConnectorResponseUpdate,
) -> StorageResult<Self> {
{
ConnectorResponseUpdate::ResponseUpdate {
connector_transaction_id,
authentication_data,
encoded_data,
connector_name,
charge_id,
updated_by,
} => PaymentAttemptUpdate::ConnectorResponse {
authentication_data,
encoded_data,
connector_transaction_id,
connector: connector_name,
charge_id,
updated_by,
},<|fim_suffix|>
<|fim_middle|>
ConnectorResponseUpdate::ErrorUpdate {
connector_name,
updated_by,
} => PaymentAttemptUpdate::ConnectorResponse {
authentication_data: None,
encoded_data: None,
connector_transaction_id: None,
connector: connector_name,
charge_id: None,
updated_by,
},
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/connector_response.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use router_env::{instrument, logger, tracing};
use super::generics;
use crate::{
connector_response::{
ConnectorResponse, ConnectorResponseNew, ConnectorResponseUpdate,
ConnectorResponseUpdateInternal,
},
errors,
payment_attempt::{PaymentAttempt, PaymentAttemptUpdate, PaymentAttemptUpdateInternal},
schema::{connector_response::dsl, payment_attempt::dsl as pa_dsl},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<ConnectorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/connector_response.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use router_env::{instrument, logger, tracing};
use super::generics;
use crate::{
connector_response::{
ConnectorResponse, ConnectorResponseNew, ConnectorResponseUpdate,
ConnectorResponseUpdateInternal,
},
errors,
payment_attempt::{PaymentAttempt, PaymentAttemptUpdate, PaymentAttemptUpdateInternal},
schema::{connector_response::dsl, payment_attempt::dsl as pa_dsl},
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
connector_response: ConnectorResponseUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use diesel::{
associations::HasTable,
query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl},
BoolExpressionMethods, ExpressionMethods,
};
use super::generics;
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn update_with_attempt_id(
self,
conn: &PgPooledConn,
payout_attempt_update: PayoutAttemptUpdate,
) -> StorageResult<Self> {
{
DatabaseError::NoFieldsToUpdate => Ok(self),<|fim_suffix|>
<|fim_middle|>
_ => Err(error),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use diesel::{
associations::HasTable,
query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl},
BoolExpressionMethods, ExpressionMethods,
};
use super::generics;
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn update_with_attempt_id(
self,
conn: &PgPooledConn,
payout_attempt_update: PayoutAttemptUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use diesel::{
associations::HasTable,
query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl},
BoolExpressionMethods, ExpressionMethods,
};
use error_stack::{report, ResultExt};
use super::generics;
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn update_by_merchant_id_payout_attempt_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
payout_attempt_id: &str,
payout: PayoutAttemptUpdate,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use diesel::{
associations::HasTable,
query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl},
BoolExpressionMethods, ExpressionMethods,
};
use error_stack::{report, ResultExt};
use super::generics;
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn update_by_merchant_id_payout_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
payout_id: &str,
payout: PayoutAttemptUpdate,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use diesel::{
associations::HasTable,
query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl},
BoolExpressionMethods, ExpressionMethods,
};
use super::generics;
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_id_connector_payout_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
connector_payout_id: &str,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use diesel::{
associations::HasTable,
query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl},
BoolExpressionMethods, ExpressionMethods,
};
use super::generics;
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_id_payout_attempt_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
payout_attempt_id: &str,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use super::generics;
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<PayoutAttempt> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payout_attempt.rs | crate: diesel_models
use std::collections::HashSet;
use diesel::{
associations::HasTable,
query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl},
BoolExpressionMethods, ExpressionMethods,
};
use crate::{
enums,
errors::DatabaseError,
payout_attempt::{
PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate, PayoutAttemptUpdateInternal,
},
schema::{payout_attempt::dsl, payouts as payout_dsl},
Payouts, PgPooledConn, StorageResult,
};
pub async fn get_filters_for_payouts(
conn: &PgPooledConn,
payouts: &[Payouts],
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<(
Vec<String>,
Vec<enums::Currency>,
Vec<enums::PayoutStatus>,
Vec<enums::PayoutType>,
)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/merchant_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
merchant_key_store::{MerchantKeyStore, MerchantKeyStoreNew},
schema::merchant_key_store::dsl,
PgPooledConn, StorageResult,
};
pub async fn list_multiple_key_stores(
conn: &PgPooledConn,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/merchant_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
merchant_key_store::{MerchantKeyStore, MerchantKeyStoreNew},
schema::merchant_key_store::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/merchant_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
merchant_key_store::{MerchantKeyStore, MerchantKeyStoreNew},
schema::merchant_key_store::dsl,
PgPooledConn, StorageResult,
};
pub async fn list_all_key_stores(
conn: &PgPooledConn,
from: u32,
limit: u32,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/merchant_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
merchant_key_store::{MerchantKeyStore, MerchantKeyStoreNew},
schema::merchant_key_store::dsl,
PgPooledConn, StorageResult,
};
pub async fn list_multiple_key_stores(
conn: &PgPooledConn,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
) -> StorageResult<Vec<Self>> {
generics::generic_filter::<
<Self as HasTable>::Table,
_,
<<Self as HasTable>::Table as diesel::Table>::PrimaryKey,
_,
>(
conn,
dsl::merchant_id.eq_any(merchant_ids),
None,
None,
None,
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/merchant_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
merchant_key_store::{MerchantKeyStore, MerchantKeyStoreNew},
schema::merchant_key_store::dsl,
PgPooledConn, StorageResult,
};
pub async fn delete_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<bool> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/merchant_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
merchant_key_store::{MerchantKeyStore, MerchantKeyStoreNew},
schema::merchant_key_store::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::merchant_id.eq(merchant_id.to_owned()),
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/merchant_key_store.rs | crate: diesel_models
use super::generics;
use crate::{
merchant_key_store::{MerchantKeyStore, MerchantKeyStoreNew},
schema::merchant_key_store::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<MerchantKeyStore> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_key_store.rs | crate: diesel_models
use super::generics;
use crate::{
schema::user_key_store::dsl,
user_key_store::{UserKeyStore, UserKeyStoreNew},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<UserKeyStore> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
schema::user_key_store::dsl,
user_key_store::{UserKeyStore, UserKeyStoreNew},
PgPooledConn, StorageResult,
};
pub async fn find_by_user_id(conn: &PgPooledConn, user_id: &str) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_key_store.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
schema::user_key_store::dsl,
user_key_store::{UserKeyStore, UserKeyStoreNew},
PgPooledConn, StorageResult,
};
pub async fn get_all_user_key_stores(
conn: &PgPooledConn,
from: u32,
limit: u32,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/user_key_store.rs | crate: diesel_models
use super::generics;
use crate::{
schema::user_key_store::dsl,
user_key_store::{UserKeyStore, UserKeyStoreNew},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<UserKeyStore> {
generics::generic_insert(conn, self).await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/mandate.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use error_stack::report;
use super::generics;
use crate::{errors, mandate::*, schema::mandate::dsl, PgPooledConn, StorageResult};
pub async fn update_by_merchant_id_mandate_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
mandate_id: &str,
mandate: MandateUpdateInternal,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/mandate.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use error_stack::report;
use super::generics;
use crate::{errors, mandate::*, schema::mandate::dsl, PgPooledConn, StorageResult};
pub async fn update_by_merchant_id_mandate_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
mandate_id: &str,
mandate: MandateUpdateInternal,
) -> StorageResult<Self> {
generics::generic_update_with_results::<<Self as HasTable>::Table, _, _, _>(
conn,
dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::mandate_id.eq(mandate_id.to_owned())),
mandate,
)
.await?
.first()
.cloned()
.ok_or_else(|| {
report!(errors::DatabaseError::NotFound)
.attach_printable("Error while updating mandate")
})
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/mandate.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{errors, mandate::*, schema::mandate::dsl, PgPooledConn, StorageResult};
pub async fn find_by_global_customer_id(
conn: &PgPooledConn,
customer_id: &common_utils::id_type::GlobalCustomerId,
) -> StorageResult<Vec<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/mandate.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{errors, mandate::*, schema::mandate::dsl, PgPooledConn, StorageResult};
pub async fn find_by_merchant_id_customer_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
customer_id: &common_utils::id_type::CustomerId,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/mandate.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{errors, mandate::*, schema::mandate::dsl, PgPooledConn, StorageResult};
pub async fn find_by_merchant_id_connector_mandate_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
connector_mandate_id: &str,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/mandate.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};
use super::generics;
use crate::{errors, mandate::*, schema::mandate::dsl, PgPooledConn, StorageResult};
pub async fn find_by_merchant_id_mandate_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
mandate_id: &str,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/mandate.rs | crate: diesel_models
use super::generics;
use crate::{errors, mandate::*, schema::mandate::dsl, PgPooledConn, StorageResult};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Mandate> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::schema::payment_intent::dsl;
use crate::schema_v2::payment_intent::dsl;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
payment_intent: payment_intent::PaymentIntentUpdate,
) -> StorageResult<Self> {
{
errors::DatabaseError::NoFieldsToUpdate => Ok(self),<|fim_suffix|>
<|fim_middle|>
_ => Err(error),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::schema::payment_intent::dsl;
use crate::schema_v2::payment_intent::dsl;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn find_optional_by_merchant_reference_id_merchant_id(
conn: &PgPooledConn,
merchant_reference_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Option<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::schema::payment_intent::dsl;
use crate::schema_v2::payment_intent::dsl;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn find_by_payment_id_merchant_id(
conn: &PgPooledConn,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::schema::payment_intent::dsl;
use crate::schema_v2::payment_intent::dsl;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_reference_id_profile_id(
conn: &PgPooledConn,
merchant_reference_id: &common_utils::id_type::PaymentReferenceId,
profile_id: &common_utils::id_type::ProfileId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::schema::payment_intent::dsl;
use crate::schema_v2::payment_intent::dsl;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_reference_id_merchant_id(
conn: &PgPooledConn,
merchant_reference_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::schema::payment_intent::dsl;
use crate::schema_v2::payment_intent::dsl;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
payment_intent: payment_intent::PaymentIntentUpdate,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn find_by_global_id(
conn: &PgPooledConn,
id: &common_utils::id_type::GlobalPaymentId,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::schema::payment_intent::dsl;
use crate::schema_v2::payment_intent::dsl;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
payment_intent_update: payment_intent::PaymentIntentUpdateInternal,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/payment_intent.rs | crate: diesel_models
use super::generics;
use crate::{
errors,
payment_intent::{self, PaymentIntent, PaymentIntentNew},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<PaymentIntent> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/capture.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
capture::{Capture, CaptureNew, CaptureUpdate, CaptureUpdateInternal},
errors,
schema::captures::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_with_capture_id(
self,
conn: &PgPooledConn,
capture: CaptureUpdate,
) -> StorageResult<Self> {
{
Err(error) => match error.current_context() {
errors::DatabaseError::NoFieldsToUpdate => Ok(self),
_ => Err(error),
},<|fim_suffix|>
<|fim_middle|>
result => result,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/capture.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
capture::{Capture, CaptureNew, CaptureUpdate, CaptureUpdateInternal},
errors,
schema::captures::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_capture_id(conn: &PgPooledConn, capture_id: &str) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/capture.rs | crate: diesel_models
use common_utils::types::ConnectorTransactionIdTrait;
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
capture::{Capture, CaptureNew, CaptureUpdate, CaptureUpdateInternal},
errors,
schema::captures::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_all_by_merchant_id_payment_id_authorized_attempt_id(
merchant_id: &common_utils::id_type::MerchantId,
payment_id: &common_utils::id_type::PaymentId,
authorized_attempt_id: &str,
conn: &PgPooledConn,
) -> StorageResult<Vec<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/capture.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
capture::{Capture, CaptureNew, CaptureUpdate, CaptureUpdateInternal},
errors,
schema::captures::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_with_capture_id(
self,
conn: &PgPooledConn,
capture: CaptureUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/diesel_models/src/query/capture.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
capture::{Capture, CaptureNew, CaptureUpdate, CaptureUpdateInternal},
errors,
schema::captures::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_capture_id(conn: &PgPooledConn, capture_id: &str) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::capture_id.eq(capture_id.to_owned()),
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/capture.rs | crate: diesel_models
use super::generics;
use crate::{
capture::{Capture, CaptureNew, CaptureUpdate, CaptureUpdateInternal},
errors,
schema::captures::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Capture> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.