What do you think about this code for functions that take both pool and transaction? #2266
Unanswered
frederikhors
asked this question in
Q&A
Replies: 1 comment 2 replies
-
I was looking to achieve a similar result, and found this discussion, which, as long as you are using 0.6+, says that you can do something like this; pub async fn insert(postgres: impl PgExecutor<'_>, email: &str) -> Result<Self, ApiError> {
// actual query here etc
} which will enable you to use this |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying sqlx for the first time these days, sorry if this is a dumb question.
I'm writing a function that I want to take both
PgPool
andTransaction<Postgres>
.I'm using the below (SIMPLIFIED) code:
Is this good enough or is there a better way to write it (maybe avoiding the lifetimes in
impl sqlx::PgExecutor<'a>
)?Beta Was this translation helpful? Give feedback.
All reactions