1 Star 0 Fork 0

ckbabby / xorm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
find.go 686 Bytes
一键复制 编辑 原始数据 按行查看 历史
lunny 提交于 2017-01-09 09:52 . some gofmt & golint fixed
package main
import (
"fmt"
"os"
"time"
"github.com/go-xorm/xorm"
)
// User describes a user
type User struct {
Id int64
Name string
Created time.Time `xorm:"created"`
Updated time.Time `xorm:"updated"`
}
func main() {
f := "conversion.db"
os.Remove(f)
orm, err := xorm.NewEngine("sqlite3", f)
if err != nil {
fmt.Println(err)
return
}
orm.ShowSQL(true)
err = orm.CreateTables(&User{})
if err != nil {
fmt.Println(err)
return
}
_, err = orm.Insert(&User{Id: 1, Name: "xlw"})
if err != nil {
fmt.Println(err)
return
}
users := make([]User, 0)
err = orm.Find(&users)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(users)
}
1
https://gitee.com/ckbabby/xorm.git
git@gitee.com:ckbabby/xorm.git
ckbabby
xorm
xorm
v0.6.4

搜索帮助

53164aa7 5694891 3bd8fe86 5694891