You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if err != nil {
c.Status(http.StatusBadRequest).JSON(
&fiber.Map{"message": "could not create book"})
return err
}
var todos []Todo
db.Find(&todos)
return c.JSON(todos)
})`
i get the following error:
2022/10/16 22:12:37 C:/Users/xxx/go/src/go-todo-app/server/main.go:38 Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RETURNING id' at line 1
[0.550ms] [rows:0] INSERT INTO todos (title,done,body) VALUES ('Testing',0,'Finish Tutorial') RETURNING id
The text was updated successfully, but these errors were encountered:
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Hello,
I have some code to create a todo. but it doesnt work.
type Todo struct { ID uint
gorm:"primary key;autoIncrement" json:"id"Title string
json:"title"Done int
json:"done"Body string
json:"body"`}
app.Post("/api/todos", func(c *fiber.Ctx) error {
todo := &Todo{}
if err := c.BodyParser(todo); err != nil {
return err
}
err := db.Create(&todo).Error // does not work
if err != nil {
c.Status(http.StatusBadRequest).JSON(
&fiber.Map{"message": "could not create book"})
return err
}
var todos []Todo
db.Find(&todos)
return c.JSON(todos)
})`
i get the following error:
2022/10/16 22:12:37 C:/Users/xxx/go/src/go-todo-app/server/main.go:38 Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RETURNING
id
' at line 1[0.550ms] [rows:0] INSERT INTO
todos
(title
,done
,body
) VALUES ('Testing',0,'Finish Tutorial') RETURNINGid
The text was updated successfully, but these errors were encountered: