Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cute-angelia/sql-scheme-to-gorm
mysql schme file convert golang model , for gorm ...
https://github.com/cute-angelia/sql-scheme-to-gorm
Last synced: 22 days ago
JSON representation
mysql schme file convert golang model , for gorm ...
- Host: GitHub
- URL: https://github.com/cute-angelia/sql-scheme-to-gorm
- Owner: cute-angelia
- Created: 2019-08-03T08:26:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-05T07:26:07.000Z (6 months ago)
- Last Synced: 2024-10-15T04:32:32.095Z (3 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/mysql2gomodel
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# sql 结构转 gorm model
把 sql 创建语句转成 gorm model
### install
`npm i sql-to-gorm --location=global`
### CLI usage Example
```
# 打印
$ sql-to-gorm [input-file]# 写入文件
$ sql-to-gorm schema.sql > schema.go```
demo ----- print -----
```
package modeltype TaskSyncPaopaoTwitterModel struct {
Id int32 `json:"id" gorm:"column:id;int(11) unsigned;comment:'自增id'"`
Username string `json:"username" gorm:"column:username;varchar(50);default:NULL"`
Nickname string `json:"nickname" gorm:"column:nickname;varchar(80);default:NULL"`
LastPostId int64 `json:"last_post_id" gorm:"column:last_post_id;bigint(20);default:'0';comment:'泡泡最后id'"`
Bucket string `json:"bucket" gorm:"column:bucket;varchar(30);default:NULL"`
ObjectDir string `json:"object_dir" gorm:"column:object_dir;varchar(80);default:NULL"`
Status int32 `json:"status" gorm:"column:status;tinyint(2);default:'1';comment:'1:on 0 :off'"`
Dateline string `json:"dateline" gorm:"column:dateline;datetime;default:NULL"`
}func (TaskSyncPaopaoTwitterModel) TableName() string {
return "task_sync_paopao_twitter"
}
```