Update README

This commit is contained in:
Jinzhu 2013-10-28 10:09:44 +08:00
parent a81b9f3950
commit c412729570
3 changed files with 22 additions and 1 deletions

View File

@ -2,6 +2,18 @@
Yet Another ORM library for Go, aims for developer friendly
## Overview
* CURD
* Chainable API
* Before/After Create/Save/Update/Delete Callbacks
* Order/Select/Limit/Offset Support
* Automatically CreatedAt, UpdatedAt
* Create table from struct
* Prevent SQL Injection
* Goroutines friendly
* Database Pool
## Basic Usage
```go
@ -16,8 +28,11 @@ type User struct {
UpdatedAt time.Time
}
// Set database pool
db.SetPool(10)
// Create
user = User{Name: "jinzhu", Age: 18, Birthday: time.Now())
user = User{Name: "jinzhu", Age: 18, Birthday: time.Now()}
db.Save(&user)
// Update

View File

@ -17,6 +17,10 @@ func Open(driver, source string) (db DB, err error) {
return
}
func (s *DB) SetPool(n int) {
s.Db.SetMaxIdleConns(n)
}
func (s *DB) buildORM() *Chain {
return &Chain{db: s.Db, driver: s.Driver}
}

View File

@ -40,6 +40,8 @@ var (
func init() {
db, _ = Open("postgres", "user=gorm dbname=gorm sslmode=disable")
db.SetPool(10)
db.Exec("drop table users;")
db.Exec("drop table products;")