这是在models中定义的一个struct,beego中的数据库名称为test_books_type
package models
import (
"github.com/astaxie/beego/orm"
)
type Books_type struct {
Guid string `orm:"pk"`
Top_guid string
Type_name string
}
func init() {
orm.RegisterModelWithPrefix("test_", new(Books_type))
}
现在的情况是我有多个models文件,见了很多struct,每个struct多对应一张数据库表,前缀为test_,我怎样才能根据得到的表的名字来创建对应的model??举例,我获得了表名为test_movie_type,我怎样创建new(models.Movie_type),求指教!
大可不必这样,既然知道了表名,直接利用原生语句插入值即可,还是太依赖经验和框架了,应该灵活处理问题