fix d1-blog-server example to use normal integer type

This commit is contained in:
syumai 2023-02-26 18:16:16 +09:00
parent adfe33a878
commit 53627e79e8

View File

@ -108,20 +108,15 @@ ORDER BY created_at DESC;
articles := []model.Article{} articles := []model.Article{}
for rows.Next() { for rows.Next() {
var ( var a model.Article
title, body string err = rows.Scan(&a.ID, &a.Title, &a.Body, &a.CreatedAt)
id, createdAt float64 // number value is always retrieved as float64.
)
err = rows.Scan(&id, &title, &body, &createdAt)
if err != nil { if err != nil {
break log.Println(err)
h.handleErr(w, http.StatusInternalServerError,
"failed to scan article")
return
} }
articles = append(articles, model.Article{ articles = append(articles, a)
ID: uint64(id),
Title: title,
Body: body,
CreatedAt: uint64(createdAt),
})
} }
res := model.ListArticlesResponse{ res := model.ListArticlesResponse{
Articles: articles, Articles: articles,