feat: let database handles creation times

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-12-05 02:30:51 +03:00
parent 1e8d656711
commit dca2abb62a
10 changed files with 22 additions and 22 deletions

View file

@ -7,17 +7,18 @@ pub async fn create(
post_creation_time: &DateTime<Utc>,
interaction_id: i64,
interactor_id: i64,
interaction_time: &DateTime<Utc>,
database_connection: &Pool<Postgres>,
) -> Result<PostInteraction, sqlx::Error> {
sqlx::query_as!(
PostInteraction,
r#"
INSERT INTO "post_interaction"(post_creation_time, interaction_id, interactor_id, interaction_time)
VALUES ($1, $2, $3, $4)
INSERT INTO "post_interaction"(post_creation_time, interaction_id, interactor_id)
VALUES ($1, $2, $3)
RETURNING *
"#,
post_creation_time, interaction_id, interactor_id, interaction_time,
post_creation_time,
interaction_id,
interactor_id,
)
.fetch_one(database_connection)
.await