Coder Social home page Coder Social logo

Comments (1)

xinliangnote avatar xinliangnote commented on July 21, 2024

以下基于commit:9aa0067e07d036b4ae57168d2bd138d142dff80e 建议使用gorm在程序初始化的时候创建表,eg:

type User struct {
	//通过在字段后面的标签说明,定义golang字段和表字段的关系
	//例如 `gorm:"column:username"` 标签说明含义是: Mysql表的列名(字段名)为username
	//这里golang定义的Username变量和MYSQL表字段username一样,他们的名字可以不一样。
	Id int64 `gorm:"column:username;not null;type:int(4) primary key auto_increment;comment:'用户名'"`
	Password string `gorm:"column:password;type:varchar(30);index:idx_name"`
	//创建时间,时间戳
	CreateTime int64 `gorm:"column:createtime"`
}

同时建议不要在代码中直接写sql eg:internal/api/controller/tool_handler/func_tables.go:48 切换数据库的时候很痛苦 (postgres要在连接的时候指定数据库,Oracle要在连接的时候指定用户) 谢谢

sorry,目前还不支持,主要是因为作者不会。

from go-gin-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.