I'm receiving the following error when trying to SELECT with gorp:
No table found for type: Post
Here's what my code looks like:
type Post struct {
Id int64 `db:"post_id"`
CreatedAt int64 `db:"created_at"`
UpdatedAt int64 `db:"updated"`
Title string `db:"title"`
}
var list []*Post
_, err := dbMapper.Select(&list, "SELECT * FROM posts")
if (err != nil) {
fmt.Fprintf(writer, "%s", err)
return
}
for _, item := range list {
fmt.Fprintf(writer, "%s
", item.Title)
}
I'm adding the table like this:
dbMapper.AddTableWithName(Post{}, "posts").SetKeys(true, "Id")