data: return newly crated entries in SQL
This commit is contained in:
parent
fb8bf0f316
commit
93182705d9
2 changed files with 13 additions and 11 deletions
|
@ -28,12 +28,13 @@ impl PgFollowDataSource {
|
|||
T: Into<NewFollow> + Send,
|
||||
{
|
||||
let new = new.into();
|
||||
let follow: Follow =
|
||||
sqlx::query_as("INSERT INTO follows (follower_id, followee_id) VALUES ($1, $2)")
|
||||
.bind(new.follower_id)
|
||||
.bind(new.followee_id)
|
||||
.fetch_one(&self.pool)
|
||||
.await?;
|
||||
let follow: Follow = sqlx::query_as(
|
||||
"INSERT INTO follows (follower_id, followee_id) VALUES ($1, $2) RETURNING *",
|
||||
)
|
||||
.bind(new.follower_id)
|
||||
.bind(new.followee_id)
|
||||
.fetch_one(&self.pool)
|
||||
.await?;
|
||||
Ok(follow)
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,12 @@ impl PgLikeDataSource {
|
|||
E: Into<Error>,
|
||||
{
|
||||
let new = new.try_into().map_err(|e| e.into())?.inner();
|
||||
let like: Like = sqlx::query_as("INSERT INTO likes (note_id, account_id) VALUES ($1, $2)")
|
||||
.bind(new.note_id)
|
||||
.bind(new.account_id)
|
||||
.fetch_one(&self.pool)
|
||||
.await?;
|
||||
let like: Like =
|
||||
sqlx::query_as("INSERT INTO likes (note_id, account_id) VALUES ($1, $2) RETURNING *")
|
||||
.bind(new.note_id)
|
||||
.bind(new.account_id)
|
||||
.fetch_one(&self.pool)
|
||||
.await?;
|
||||
Ok(like)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue