代码拉取完成,页面将自动刷新
同步操作将从 goflyfox/gfstudy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
现在gen命令主要是生成model
模型生成采用了Active Record
设计模式。该命令将会根据数据表名生成对应的目录,该目录名称即数据表包名。目录下自动生成3个文件:
数据表名.go
自定义文件,开发者可以自由定义填充的代码文件,仅会生成一次,每一次模型生成不会覆盖。数据表名_entity.go
表结构文件,根据数据表结构生成的结构体定义文件,包含字段注释。数据表在外部变更后,可使用gen
命令重复生成更新该文件。数据表名_model.go
表模型文件,为数据表提供了许多便捷的CURD
操作方法,并可直接查询返回该表的结构体对象。数据表在外部变更后,可使用gen
命令重复生成更新该文件。D:\17.gfcli> gf gen -h
USAGE
gf gen model [PATH] [OPTION]
ARGUMENT
PATH the destination for storing generated files, not necessary, default is "./app/model"
OPTION
-l, --link database configuration, please refer to: https://goframe.org/database/gdb/config
-t, --table generate models only for given tables, multiple table names separated with ','
-g, --group used with "-c" option, specifying the configuration group name for database,
it's not necessary and the default value is "default"
-c, --config used to specify the configuration file for database, it's commonly not necessary.
If "-l" is not passed, it will search "./config.toml" and "./config/config.toml"
in current working directory in default.
-p, --prefix remove specified prefix of the table, multiple prefix separated with ','
EXAMPLES
gf gen model
gf gen model -l "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
gf gen model ./model -l "mssql:sqlserver://sa:12345678@127.0.0.1:1433?database=test"
gf gen model ./model -c config.yaml -g user-center -t user,user_detail,user_login
gf gen model -p user_,p_
DESCRIPTION
The "gen" command is designed for multiple generating purposes.
It's currently supporting generating go files for ORM models.
PS D:\17.gfcli> gf gen model ./model -c config/config.toml -p sys_ -t sys_user
2020-04-26 23:35:31.682 [DEBU] [ 51 ms] SHOW FULL COLUMNS FROM `sys_user`
generated: ./model\user\user.go
generated: ./model\user\user_entity.go
generated: ./model\user\user_model.go
done!
D:\17.gfcli> tree /f .\model
卷 Data 的文件夹 PATH 列表
卷序列号为 DA91-D877
D:\17.GFCLI\MODEL
└─user
user.go
user_entity.go
user_model.go
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。