github.com/unionj-cloud/go-doudou/v2@v2.3.5/toolkit/gormgen/tools/gentool/README.md (about) 1 # GenTool 2 3 Install GEN as a binary tool 4 5 ## install 6 7 ```shell 8 go install gorm.io/gen/tools/gentool@latest 9 ``` 10 11 ## usage 12 13 ```shell 14 15 gentool -h 16 17 Usage of gentool: 18 -db string 19 input mysql|postgres|sqlite|sqlserver|clickhouse. consult[https://gorm.io/docs/connecting_to_the_database.html] (default "mysql") 20 -dsn string 21 consult[https://gorm.io/docs/connecting_to_the_database.html] 22 -fieldNullable 23 generate with pointer when field is nullable 24 -fieldWithIndexTag 25 generate field with gorm index tag 26 -fieldWithTypeTag 27 generate field with gorm column type tag 28 -modelPkgName string 29 generated model code's package name 30 -outFile string 31 query code file name, default: gen.go 32 -outPath string 33 specify a directory for output (default "./dao/query") 34 -tables string 35 enter the required data table or leave it blank 36 -onlyModel 37 only generate models (without query file) 38 -withUnitTest 39 generate unit test for query code 40 -fieldSignable 41 detect integer field's unsigned type, adjust generated data type 42 43 ``` 44 #### c 45 default "" 46 Is path for gen.yml 47 Replace the command line with a configuration file 48 The command line is the highest priority 49 50 51 #### db 52 53 default:mysql 54 55 input mysql or postgres or sqlite or sqlserver. 56 57 consult : https://gorm.io/docs/connecting_to_the_database.html 58 59 #### dsn 60 61 You can use all gorm's dsn. 62 63 consult : https://gorm.io/docs/connecting_to_the_database.html 64 65 #### fieldNullable 66 67 generate with pointer when field is nullable 68 69 #### fieldWithIndexTag 70 71 generate field with gorm index tag 72 73 #### fieldWithTypeTag 74 75 generate field with gorm column type tag 76 77 #### modelPkgName 78 79 defalut table name. 80 81 generated model code's package name. 82 83 #### outFile 84 85 query code file name, default: gen.go 86 87 #### outPath 88 89 specify a directory for output (default "./dao/query") 90 91 #### tables 92 93 Value : enter the required data table or leave it blank. 94 95 eg : 96 97 --tables="orders" #orders table 98 99 --tables="orders,users" #orders table and users table 100 101 --tables="" # All data tables in the database. 102 103 Generate some tables code. 104 105 #### withUnitTest 106 107 Value : False / True 108 109 Generate unit test. 110 111 #### fieldSignable 112 113 Value : False / True 114 115 detect integer field's unsigned type, adjust generated data type 116 117 118 119 ### example 120 121 ```shell 122 gentool -dsn "user:pwd@tcp(127.0.0.1:3306)/database?charset=utf8mb4&parseTime=True&loc=Local" -tables "orders,doctor" 123 ```