mirror of https://github.com/go-gorm/gorm.git
Update Document
This commit is contained in:
parent
fc8f0e53c8
commit
8e415788d5
46
README.md
46
README.md
|
@ -45,22 +45,22 @@ http://godoc.org/github.com/jinzhu/gorm
|
||||||
- [Initialize Database](#initialize-database)
|
- [Initialize Database](#initialize-database)
|
||||||
- [Migration](#migration)
|
- [Migration](#migration)
|
||||||
- [Basic CRUD](#basic-crud)
|
- [Basic CRUD](#basic-crud)
|
||||||
- [Create Record](#create-record)
|
- [Create](#create-record)
|
||||||
- [Query](#query)
|
- [Query](#query)
|
||||||
- [Query With Where (Plain SQL)](#query-with-where-plain-sql)
|
- [Query With Where (Plain SQL)](#query-with-where-plain-sql)
|
||||||
- [Query With Where (Struct & Map)](#query-with-where-struct--map)
|
- [Query With Where (Struct & Map)](#query-with-where-struct--map)
|
||||||
- [Query With Not](#query-with-not)
|
- [Query With Not](#query-with-not)
|
||||||
- [Query With Inline Condition](#query-with-inline-condition)
|
- [Query With Inline Condition](#query-with-inline-condition)
|
||||||
- [Query With Or](#query-with-or)
|
- [Query With Or](#query-with-or)
|
||||||
- [Query Chains](#query-chains)
|
- [Query Chains](#query-chains)
|
||||||
- [Preloading (Eager loading)](#preloading-eager-loading)
|
- [Preloading (Eager loading)](#preloading-eager-loading)
|
||||||
- [Update](#update)
|
- [Update](#update)
|
||||||
- [Update Without Callbacks](#update-without-callbacks)
|
- [Update Without Callbacks](#update-without-callbacks)
|
||||||
- [Batch Updates](#batch-updates)
|
- [Batch Updates](#batch-updates)
|
||||||
- [Update with SQL Expression](#update-with-sql-expression)
|
- [Update with SQL Expression](#update-with-sql-expression)
|
||||||
- [Delete](#delete)
|
- [Delete](#delete)
|
||||||
- [Batch Delete](#batch-delete)
|
- [Batch Delete](#batch-delete)
|
||||||
- [Soft Delete](#soft-delete)
|
- [Soft Delete](#soft-delete)
|
||||||
- [Associations](#associations)
|
- [Associations](#associations)
|
||||||
- [Has One](#has-one)
|
- [Has One](#has-one)
|
||||||
- [Belongs To](#belongs-to)
|
- [Belongs To](#belongs-to)
|
||||||
|
@ -1217,7 +1217,15 @@ db.Model(&User{}).RemoveIndex("idx_user_name")
|
||||||
|
|
||||||
## Default values
|
## Default values
|
||||||
|
|
||||||
If you have defined a default value in the `sql` tag (see the struct Animal above) the generated create/update SQl will ignore these fields if is set blank data.
|
```go
|
||||||
|
type Animal struct {
|
||||||
|
ID int64
|
||||||
|
Name string `sql:"default:'galeone'"`
|
||||||
|
Age int64
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you have defined a default value in the `sql` tag, the generated create SQl will ignore these fields if it is blank.
|
||||||
|
|
||||||
Eg.
|
Eg.
|
||||||
|
|
||||||
|
@ -1225,7 +1233,7 @@ Eg.
|
||||||
db.Create(&Animal{Age: 99, Name: ""})
|
db.Create(&Animal{Age: 99, Name: ""})
|
||||||
```
|
```
|
||||||
|
|
||||||
The generated query will be:
|
The generated SQL will be:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
INSERT INTO animals("age") values('99');
|
INSERT INTO animals("age") values('99');
|
||||||
|
@ -1286,5 +1294,3 @@ db.Where("email = ?", "x@example.org").Attrs(User{RegisteredIp: "111.111.111.111
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Released under the [MIT License](https://github.com/jinzhu/gorm/blob/master/License).
|
Released under the [MIT License](https://github.com/jinzhu/gorm/blob/master/License).
|
||||||
|
|
||||||
[![GoDoc](https://godoc.org/github.com/jinzhu/gorm?status.png)](http://godoc.org/github.com/jinzhu/gorm)
|
|
||||||
|
|
Loading…
Reference in New Issue