-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(router): add db interface for
/relay
(#6879)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
977cb70
commit 0f8b0b3
Showing
29 changed files
with
1,152 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use diesel::{associations::HasTable, ExpressionMethods}; | ||
|
||
use super::generics; | ||
use crate::{ | ||
errors, | ||
relay::{Relay, RelayNew, RelayUpdateInternal}, | ||
schema::relay::dsl, | ||
PgPooledConn, StorageResult, | ||
}; | ||
|
||
impl RelayNew { | ||
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Relay> { | ||
generics::generic_insert(conn, self).await | ||
} | ||
} | ||
|
||
impl Relay { | ||
pub async fn update( | ||
self, | ||
conn: &PgPooledConn, | ||
relay: RelayUpdateInternal, | ||
) -> StorageResult<Self> { | ||
match generics::generic_update_with_unique_predicate_get_result::< | ||
<Self as HasTable>::Table, | ||
_, | ||
_, | ||
_, | ||
>(conn, dsl::id.eq(self.id.to_owned()), relay) | ||
.await | ||
{ | ||
Err(error) => match error.current_context() { | ||
errors::DatabaseError::NoFieldsToUpdate => Ok(self), | ||
_ => Err(error), | ||
}, | ||
result => result, | ||
} | ||
} | ||
} |
Oops, something went wrong.