- generate struct file by DB tables
- one table has many struct
- persist mappers from table column to struct attributes
go get -u github.com/DaoYoung/gen-model
- run
init
command, you will see.gen-model.yaml
cd ${your_project_dir}
gen-model init
- change
mysql.*
gen.searchTableName
value in.gen-model.yaml
, then run
gen-model create
- create local mappers for struct
gen-model create --persist=local-mapper
# it will fail, when run after step 2, because struct file is already exist, it's avoid to cover whole file. you can set `-f=true` to cover it.
gen-model create --persist=local-mapper -f=true
- rename mapper file from
${struct}FieldMapper.yaml
to${struct}VOFieldMapper.yaml
, and delete one line after fields
gen-model create --source=local-mapper --forceCover=true --modelSuffix=VO
# it will generate `${struct}VO.go`
- persist mapper data in database just use
db-mapper
instead oflocal-mapper
.
gen-model create --persist=db-mapper --forceCover=true
# it means, you can manage struct for multiple project.
# this require mysql `Create` privilege
- see what gen-model can do.
gen-model -h
gen-model create -h # commend `create` help