gorm/doc
Jinzhu 547210665d Update Documents 2016-02-26 21:55:15 +08:00
..
.gitignore Update document 2016-02-24 23:30:44 +08:00
README.md Update README 2016-02-25 22:58:56 +08:00
SUMMARY.md Update Documents 2016-02-26 21:55:15 +08:00
advanced.md Update Documents 2016-02-26 21:55:15 +08:00
associations.md Update Documents 2016-02-26 21:55:15 +08:00
book.json Update Documents 2016-02-26 21:55:15 +08:00
callbacks.md Update Documents 2016-02-26 21:55:15 +08:00
curd.md Update Documents 2016-02-26 21:55:15 +08:00
database.md Update Documents 2016-02-26 21:55:15 +08:00
development.md Update Documents 2016-02-26 21:55:15 +08:00
logger.png Move logger images to doc 2016-01-17 21:01:18 +08:00
models.md Update Documents 2016-02-26 21:55:15 +08:00

README.md

GORM

The fantastic ORM library for Golang, aims to be developer friendly.

wercker status GoDoc Join the chat at https://gitter.im/jinzhu/gorm

Overview

  • Full-Featured ORM (almost)
  • Chainable API
  • Auto Migrations
  • Relations (Has One, Has Many, Belongs To, Many To Many, Polymorphism)
  • Callbacks (Before/After Create/Save/Update/Delete/Find)
  • Preloading (eager loading)
  • Transactions
  • Embed Anonymous Struct
  • Soft Deletes
  • Customizable Logger
  • Iteration Support via Rows
  • Every feature comes with tests
  • Developer Friendly

Install

go get -u github.com/jinzhu/gorm

Basic Usage

type Product struct {
  gorm.Model
  Code string
  Price uint
}

var db *gorm.DB

func init() {
  var err error
  db, err = gorm.Open("sqlite", "test.db")
}

func main() {
  db.Create(&Product{Code: "L1212", Price: 1000})

  var product Product
  db.First(&product, 1) // find product with id 1
  db.First(&product, "code = ?", "L1212") // find product with code l1212

  db.Model(&product).Update("Price", 2000) // update product's price to 2000

  db.Delete(&product) // delete product
}

Author

jinzhu

Contributors

https://github.com/jinzhu/gorm/graphs/contributors

License

Released under the MIT License.