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,
|
T: Into<NewFollow> + Send,
|
||||||
{
|
{
|
||||||
let new = new.into();
|
let new = new.into();
|
||||||
let follow: Follow =
|
let follow: Follow = sqlx::query_as(
|
||||||
sqlx::query_as("INSERT INTO follows (follower_id, followee_id) VALUES ($1, $2)")
|
"INSERT INTO follows (follower_id, followee_id) VALUES ($1, $2) RETURNING *",
|
||||||
.bind(new.follower_id)
|
)
|
||||||
.bind(new.followee_id)
|
.bind(new.follower_id)
|
||||||
.fetch_one(&self.pool)
|
.bind(new.followee_id)
|
||||||
.await?;
|
.fetch_one(&self.pool)
|
||||||
|
.await?;
|
||||||
Ok(follow)
|
Ok(follow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,12 @@ impl PgLikeDataSource {
|
||||||
E: Into<Error>,
|
E: Into<Error>,
|
||||||
{
|
{
|
||||||
let new = new.try_into().map_err(|e| e.into())?.inner();
|
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)")
|
let like: Like =
|
||||||
.bind(new.note_id)
|
sqlx::query_as("INSERT INTO likes (note_id, account_id) VALUES ($1, $2) RETURNING *")
|
||||||
.bind(new.account_id)
|
.bind(new.note_id)
|
||||||
.fetch_one(&self.pool)
|
.bind(new.account_id)
|
||||||
.await?;
|
.fetch_one(&self.pool)
|
||||||
|
.await?;
|
||||||
Ok(like)
|
Ok(like)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue