feat(idx) add auto idx

This commit is contained in:
lumither committed 2024-05-03 21:40:53 +08:00
1 parent 6b311ab255
commit 36825b4950
8 files changed
+115 -17

No files matched your search

+6 -6
View File
@@ -29,30 +29,30 @@ pub async fn refresh(
let post_list: Vec<Post> = md_list
.into_iter()
.map(Post::from_path)
.map(|post| Post::from_path(post).unwrap())
.collect();
for post in post_list {
match query(
r##"
INSERT INTO Post (post_id, title, content, last_update)
VALUES ($1, $2, $3, $4)
INSERT INTO Post (post_id, title, summary, content, last_update)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (post_id)
DO UPDATE SET title = excluded.title,
summary = excluded.summary,
content = excluded.content,
last_update = excluded.last_update
"##,
)
.bind(post.post_id)
.bind(post.title)
.bind(post.summary)
.bind(post.content)
.bind(post.last_update)
.execute(&db_connection)
.await
{
Ok(_) => {
dbg!("inserted");
}
Ok(_) => {}
Err(e) => {
return Err((
StatusCode::INTERNAL_SERVER_ERROR,