Gorm is a complete ORM for Go. Kwiscale/Gorm is a simple wrapper to be able to implement database in framework.
In your main package, simply import and initialize database connection.
package main
import (
"gopkg.in/kwiscale/framework.v1""gopkg.in/kwiscale/orm.v1"
_ "gopkg.in/kwiscale/orm.v1/dialects/sqlite"
)
// User is a simple orm.ModeltypeUserstruct {
orm.ModelNamestringAgeint
}
funcinit() {
orm.Initialize("sqlite", "./test.db")
db:=orm.Get()
deferdb.Close()
// Create table, update if neededdb.AutoMigrate(&User{})
}Then, you may insert, delete, find, and so on.
user:=User{
Name: "Foo",
Age: 42,
}
db:=orm.Get()
deferdb.Close()
db.Create(&user)
// find a user and set it on// "res" structureres:=User{}
db.First(&res, &User{Name:"Foo"})To get more information on requests, see Gorm documentation
