mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
fix d1-blog-server example to use normal integer type
This commit is contained in:
parent
adfe33a878
commit
53627e79e8
@ -108,20 +108,15 @@ ORDER BY created_at DESC;
|
||||
|
||||
articles := []model.Article{}
|
||||
for rows.Next() {
|
||||
var (
|
||||
title, body string
|
||||
id, createdAt float64 // number value is always retrieved as float64.
|
||||
)
|
||||
err = rows.Scan(&id, &title, &body, &createdAt)
|
||||
var a model.Article
|
||||
err = rows.Scan(&a.ID, &a.Title, &a.Body, &a.CreatedAt)
|
||||
if err != nil {
|
||||
break
|
||||
log.Println(err)
|
||||
h.handleErr(w, http.StatusInternalServerError,
|
||||
"failed to scan article")
|
||||
return
|
||||
}
|
||||
articles = append(articles, model.Article{
|
||||
ID: uint64(id),
|
||||
Title: title,
|
||||
Body: body,
|
||||
CreatedAt: uint64(createdAt),
|
||||
})
|
||||
articles = append(articles, a)
|
||||
}
|
||||
res := model.ListArticlesResponse{
|
||||
Articles: articles,
|
||||
|
Loading…
x
Reference in New Issue
Block a user