gen-model

command module
v1.0.1-0...-d19d8d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 1 Imported by: 0

README

Build Status Go Report Card codecov

中文教程

gen-model

Features
  • generate struct file by DB tables
  • one table has many struct
  • persist mappers from table column to struct attributes
Install
go get -u github.com/DaoYoung/gen-model
Usage
  1. run init commend, you will see .gen-model.yaml
cd ${your_project_dir}
gen-model init
  1. change mysql.* gen.searchTableName value in .gen-model.yaml, then run
gen-model create
  1. 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

wHZ6SO.md.gif

  1. 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`

2.gif

  1. persist mapper data in database just use db-mapper instead of local-mapper.
gen-model create --persist=db-mapper --forceCover=true
# it means, you can manage struct for multiple project.
# this require mysql `Create` privilege
  1. see what gen-model can do.
gen-model -h
gen-model create -h # commend `create` help

Documentation

Overview

Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL