-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
# Gorm Generator | ||
## 声明: 该项目为根据结构题生成orm操作 | ||
## 只支持go 1.16版本以后 | ||
## 请使用gorm v2 | ||
## 只支持go mod | ||
声明: 该项目为根据结构体生成orm操作并只支持go 1.16版本以后其次请使用gorm v2并且只支持go mod | ||
|
||
下载项目: | ||
|
||
`go get github.com/Kotodian/gorm-gen` | ||
|
||
使用: | ||
|
||
`gorm-gen --dir=<项目结构体路径> --output=<生成文件路径>` | ||
|
||
结构体example: | ||
|
||
```go | ||
type User struct { | ||
Name string `gorm:"column:name" query:"equal,scope"` | ||
Age int `gorm:"column:age" query:"scope"` | ||
} | ||
``` | ||
|
||
结构体中的字段的tag中必须包含gorm,其次,query代表生成新的查询,equal代表Where("field = ?", xxx), scope代表范围查询 >=, <= | ||
|
||
TODO: | ||
|
||
关联结构体生成orm |