diff --git a/README.md b/README.md index 73a123cf..c774bfd8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/main.go b/main.go index 0e5f6a32..0f8d658b 100644 --- a/main.go +++ b/main.go @@ -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} } diff --git a/orm_test.go b/orm_test.go index 68365798..9399edba 100644 --- a/orm_test.go +++ b/orm_test.go @@ -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;")