Update README
This commit is contained in:
parent
92f790c463
commit
63a9e5e3ae
12
README.md
12
README.md
@ -57,7 +57,14 @@ type Address struct { // TableName: `addresses`
|
|||||||
## Opening a Database
|
## Opening a Database
|
||||||
|
|
||||||
```go
|
```go
|
||||||
db, err = Open("postgres", "user=gorm dbname=gorm sslmode=disable")
|
import "github.com/jinzhu/gorm"
|
||||||
|
import _ "github.com/lib/pq"
|
||||||
|
|
||||||
|
db, err := Open("postgres", "user=gorm dbname=gorm sslmode=disable")
|
||||||
|
|
||||||
|
// Set the maximum idle database connections
|
||||||
|
db.SetPool(100)
|
||||||
|
|
||||||
|
|
||||||
// Gorm is goroutines friendly, so you can create a global variable to keep the connection and use it everywhere like this
|
// Gorm is goroutines friendly, so you can create a global variable to keep the connection and use it everywhere like this
|
||||||
|
|
||||||
@ -69,9 +76,6 @@ func init() {
|
|||||||
panic(fmt.Sprintf("Got error when connect database, the error is '%v'", err))
|
panic(fmt.Sprintf("Got error when connect database, the error is '%v'", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the maximum idle database connections
|
|
||||||
db.SetPool(100)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Struct & Database Mapping
|
## Struct & Database Mapping
|
||||||
|
Loading…
x
Reference in New Issue
Block a user