Skip to content

Tomarron/orm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ORM - Gorm Wrapper for Kwiscale

Coverage StatusBuild Status

Gorm is a complete ORM for Go. Kwiscale/Gorm is a simple wrapper to be able to implement database in framework.

Usage

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.Model
type User struct {
	orm.Model
	Name string
	Age  int
}

func init() {
	orm.Initialize("sqlite", "./test.db")
	db := orm.Get()
	defer db.Close()
    // Create table, update if needed
	db.AutoMigrate(&User{})
}

Then, you may insert, delete, find, and so on.

user := User{
    Name: "Foo",
    Age: 42,
}

db := orm.Get()
defer db.Close()

db.Create(&user)

// find a user and set it on
// "res" structure
res:=User{}
db.First(&res, &User{Name:"Foo"})

To get more information on requests, see Gorm documentation

About

Kwiscale ORM is a wrapper on excellent GORM https://github.com/jinzhu/gorm ORM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%