mirror of https://github.com/go-gorm/gorm.git
Update Document
This commit is contained in:
parent
fc8f0e53c8
commit
8e415788d5
16
README.md
16
README.md
|
@ -45,7 +45,7 @@ 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)
|
||||||
|
@ -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