40 lines
994 B
Markdown
40 lines
994 B
Markdown
## 自动生成数据库模型和常见的 CRUD 操作
|
|
|
|
### Usage
|
|
|
|
```shell
|
|
go run cmd/gormgen/main.go -h
|
|
|
|
Usage of ./cmd/gormgen/main.go:
|
|
-dsn string
|
|
consult[https://gorm.io/docs/connecting_to_the_database.html]
|
|
-tables string
|
|
enter the required data table or leave it blank
|
|
```
|
|
|
|
#### -dsn
|
|
|
|
用于连接数据库的DSN reference: https://gorm.io/docs/connecting_to_the_database.html
|
|
|
|
#### -tables
|
|
|
|
指定要生成的表名称,默认所有表。
|
|
|
|
eg :
|
|
|
|
```shell
|
|
--tables="orders" # generate from `orders`
|
|
|
|
--tables="orders,users" # generate from `orders` and `users`
|
|
|
|
--tables="" # generate from all tables
|
|
```
|
|
|
|
## 示例
|
|
|
|
```shell
|
|
# 根目录下执行
|
|
go run cmd/gormgen/main.go -dsn "root:api2api..@tcp(sh-cynosdbmysql-grp-88th45wy.sql.tencentcdb.com:28555)/mini_chat?charset=utf8mb4&parseTime=True&loc=Local" -tables "log_operation,log_request,admin,app_keyword,app_keyword_reply,app_user,app_message_log,mini_program,mini_program_access_token"
|
|
|
|
```
|