Add more plugins

This commit is contained in:
Jinzhu 2016-02-21 18:35:08 +08:00
parent 0451101006
commit ffe86980cd
4 changed files with 79 additions and 1 deletions

View File

@ -1 +1,32 @@
# Summary
* [Getting Started](getting-started.md)
* [Database](database.md)
* [Connecting to a Database](#connecting-to-a-database)
* [Migration]()
* [Schema]()
* [Models]()
* [Model Defination]()
* [Naming Conventions & Overriding]()
* [Associations]()
* [Belongs To]()
* [Has One]()
* [Has Many]()
* [Many To Many]()
* [Polymorphism]()
* [Association Mode]()
* [CRUD: Reading and Writing Data]()
* [Create]()
* [Query]()
* [Preloading (Eager Loading)]()
* [Update]()
* [Delete / Soft Delete]()
* [Callbacks]()
* [Advanced Usage]()
* [Error Handling]()
* [Transactions]()
* [Raw SQL & SQL Builder]()
* [Composite Primary Key]()
* [Overriding Logger]()
* [Development]()
* [Write Plugins]()

View File

@ -1,3 +1,19 @@
{
"plugins": ["prism", "-highlight"]
"plugins": [
"prism", "-highlight", "toggle-chapters", "toc",
"github", "anchors", "edit-link"
],
"pluginsConfig": {
"toc": {
"addClass": true,
"className": "toc"
},
"github": {
"url": "https://github.com/jinzhu/gorm"
},
"edit-link": {
"base": "https://github.com/jinzhu/gorm/edit/gh-pages",
"label": "Edit This Page"
}
}
}

31
database.md Normal file
View File

@ -0,0 +1,31 @@
## Connecting To A Database
```go
import (
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
_ "github.com/go-sql-driver/mysql"
_ "github.com/mattn/go-sqlite3"
)
func init() {
db, err := gorm.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
// db, err := gorm.Open("mysql", "user:password@/dbname?charset=utf8&parseTime=True&loc=Local")
// db, err := gorm.Open("sqlite3", "/tmp/gorm.db")
// You can also use an existing database connection handle
// dbSql, _ := sql.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
// db, _ := gorm.Open("postgres", dbSql)
// Get database connection handle [*sql.DB](http://golang.org/pkg/database/sql/#DB)
db.DB()
// Then you could invoke `*sql.DB`'s functions with it
db.DB().Ping()
db.DB().SetMaxIdleConns(10)
db.DB().SetMaxOpenConns(100)
// Disable table name's pluralization
db.SingularTable(true)
}
```

0
getting-started.md Normal file
View File