【发布时间】:2018-01-30 02:57:26
【问题描述】:
我正在尝试使用 https://github.com/astaxie/beego/tree/master/orm 将 struct 插入到 postgres 数据库中。操作应该很简单
import "github.com/astaxie/beego/orm"
type Product struct {
ID string `orm:"pk"`
...
}
product := &Product{ID: productID}
_, err := orm.NewOrm().Insert(product)
if err != nil {
log.Fatal(err)
}
我不断得到这个; no LastInsertId available 每当代码运行时(插入成功),但我遇到了崩溃。
我知道这是由于 postgresql 的限制,因为我使用https://www.github.com/lib/pq 驱动程序。
有没有办法使用 beego/orm 解决这个问题?
【问题讨论】:
标签: postgresql go beego