当前位置: 首页 > news >正文

怎么做网站结构图cba排名最新排名

怎么做网站结构图,cba排名最新排名,做马来西亚生意的网站,营销型品牌网站建设【1】ORM: 即Object-Relational Mapping,它的作用是在关系型数据库和对象之间作一个映射,这样我们在具体的操作数据库的时候,就不需要再去和复杂的SQL语句打交道,只要像平时操作对象一样操作它们就可以了。 【2】GORM gorm是go语言的一个orm…

【1】ORM:
即Object-Relational Mapping,它的作用是在关系型数据库和对象之间作一个映射,这样我们在具体的操作数据库的时候,就不需要再去和复杂的SQL语句打交道,只要像平时操作对象一样操作它们就可以了。

【2】GORM
gorm是go语言的一个orm框架,Golang写的,开发人员友好的ORM库。

【3】中文文档:
https://gorm.io/zh_CN/docs/

【4】安装GORM:
录入安装GORM的命令

go get -u gorm.io/gorm
go get -u gorm.io/driver/mysql


案列:
【1】创建一个数据库:testgorm

package mainimport ("fmt""gorm.io/driver/mysql" //引入mysql驱动"gorm.io/gorm"
)func main() {//连接数据库://参数:指的是数据库的设置信息:用户名:密码@tcp(ip:port)/数据库名字?charset=utf8&parseTime=True&loc=Local//charset=utf8设置字符集//parseTime=True为了处理time.Time//loc=Local时区设置,与本地时区保持一致dsn := "root:root@tcp(127.0.0.1:3306)/testgorm?charset=utf8&parseTime=True&loc=Local"db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})if err != nil {panic(err) //如果出错,后续代码没有必要执行,想让程序中断,panic来执行即可}//创建表方式一:通常情况下,数据库中新建的表的名字是结构体名字的复数形式,例如结构体User,表名usersif err := db.AutoMigrate(&User{}); err != nil {panic(err)}//创建表方式二:Table方法可以指定你要创建的数据库的表名if err := db.Table("user").AutoMigrate(&User{}); err != nil {panic(err)}//删除表if !db.Migrator().HasTable(&User{}) {fmt.Println("table does not exist")} else {if err := db.Migrator().DropTable(&User{}); err != nil {panic(err)}}}// 定义结构体
type User struct {Age  intName string
}

【2】表名自定义规则

//【1】模型名称和表名的映射规则:
//1、如果模型名没有驼峰命名,那么表名就是:模型名小写+复数形式:如模型名User---》表名users
//2、如果模型名有驼峰命名,那么表名就是:大写变小写并在前面加下划线,最后加复数形式:如模型名UserInfo---》表名user_infos
//3、如果模型名有连续的大写字母,那么表名就是:连续的大写字母变小写,驼峰前加下划线,字母变小写,最后加复数形式:如模型名:DBUserInfo---》表名db_user_infos
type User struct {Age  intName string
}type MyUser struct {Age  intName string
}//自定义表名
func (MyUser) TableName() string {return "test_my_user"
}

【3】gorm.Model匿名字段

只需要再自己的模型中指定gorm.Model匿名字段,即可在数据库表中包含四个字段:ID,CreatedAt,UpdatedAt,DeletedAt
ID:主键自增长
CreatedAt:用于存储记录的创建时间
UpdatedAt:用于存储记录的修改时间
DeletedAt:用于存储记录的删除时间
代码:

type MyUser2 struct {gorm.ModelAge  intName string
}

【4】通过结构体标签gorm来实现表的约束 

(1)-: 忽略,不映射这个字段 eg:gorm:"”,适合:一些冗余字段,不想在数据库中体现,只想在结构体中体现

(2)primary key:主键eg:gorm:"primary key
(3)AUTO INCREMENT:自增 eg:`gorm:"AUTO INCREMENT"

(4)not null:不为空,默认为空 eg:gorm:"not null"
(5)index:索引,eg:gorm:"index"
创建索引并命名:eg:gorm:"index:idx name_code"

(6)unique index:唯一索引 eg:`gorm:"unique index"唯一性索引unique index和一般索引normal index最大的差异就是在索引列上增加了一层唯一约束。添加唯一性索引的数据列可以为空,但是只要存在数据值,就必须是唯一的。

(7)unique:唯-eg:gorm:"unique"

(8)column:指定列名eg:`gorm:"column:user name

(9)size:字符串长度,默认为255 eg:gorm:"size:10"`
(10)default`default:'男”默认值
(11)type:设置sql类型 eg:gorm:"type:int(2)"
PS:多个属性值之间用分号分隔

代码:

type Student struct {StuID   int    `gorm:"primary_key;AUTO_INCREMENT"`Name    string `gorm:"not null"`Age     int    `gorm:"unique_index"` //`gorm:"index:name_index"`Email   string `gorm:"unique"`Sex     string `gorm:"column:gender;size:10"`Desc    string `gorm:"-"`Classno string `gorm:"type:int"`
}


文章转载自:
http://bacteriotherapy.c7510.cn
http://admiration.c7510.cn
http://conceptive.c7510.cn
http://mugient.c7510.cn
http://crossing.c7510.cn
http://cashmere.c7510.cn
http://terminate.c7510.cn
http://underdevelop.c7510.cn
http://wrb.c7510.cn
http://avirulent.c7510.cn
http://serialisation.c7510.cn
http://clot.c7510.cn
http://autochory.c7510.cn
http://bedstraw.c7510.cn
http://gairish.c7510.cn
http://untrusty.c7510.cn
http://malefaction.c7510.cn
http://tripartite.c7510.cn
http://biochemist.c7510.cn
http://proa.c7510.cn
http://returned.c7510.cn
http://interlocution.c7510.cn
http://naltrexone.c7510.cn
http://pict.c7510.cn
http://epsom.c7510.cn
http://carshops.c7510.cn
http://ide.c7510.cn
http://betoken.c7510.cn
http://huntington.c7510.cn
http://nipup.c7510.cn
http://loden.c7510.cn
http://limehouse.c7510.cn
http://anagnorisis.c7510.cn
http://host.c7510.cn
http://maffei.c7510.cn
http://idlesse.c7510.cn
http://avertible.c7510.cn
http://humorsome.c7510.cn
http://priming.c7510.cn
http://intertropical.c7510.cn
http://analogise.c7510.cn
http://concededly.c7510.cn
http://torchon.c7510.cn
http://woodbine.c7510.cn
http://nsec.c7510.cn
http://qualm.c7510.cn
http://screamer.c7510.cn
http://fac.c7510.cn
http://gyneocracy.c7510.cn
http://mesembrianthemum.c7510.cn
http://paleface.c7510.cn
http://resupply.c7510.cn
http://bpas.c7510.cn
http://tyrol.c7510.cn
http://cinq.c7510.cn
http://decemvir.c7510.cn
http://leud.c7510.cn
http://indestructibility.c7510.cn
http://twosome.c7510.cn
http://dunite.c7510.cn
http://reflected.c7510.cn
http://mummification.c7510.cn
http://barbarise.c7510.cn
http://sociably.c7510.cn
http://tychonic.c7510.cn
http://liliaceous.c7510.cn
http://amphistylar.c7510.cn
http://greenboard.c7510.cn
http://assuredness.c7510.cn
http://proterozoic.c7510.cn
http://amniography.c7510.cn
http://semina.c7510.cn
http://salep.c7510.cn
http://oospore.c7510.cn
http://sarcophagous.c7510.cn
http://rase.c7510.cn
http://ahg.c7510.cn
http://campstool.c7510.cn
http://tostada.c7510.cn
http://hydrodynamics.c7510.cn
http://publicise.c7510.cn
http://echo.c7510.cn
http://polliwog.c7510.cn
http://shorts.c7510.cn
http://criminalist.c7510.cn
http://penes.c7510.cn
http://zein.c7510.cn
http://aposelenium.c7510.cn
http://placename.c7510.cn
http://rummage.c7510.cn
http://porridge.c7510.cn
http://bagworm.c7510.cn
http://aparejo.c7510.cn
http://hagridden.c7510.cn
http://isospory.c7510.cn
http://penna.c7510.cn
http://dogfall.c7510.cn
http://phosphorylcholine.c7510.cn
http://loanword.c7510.cn
http://rectification.c7510.cn
http://www.zhongyajixie.com/news/95307.html

相关文章:

  • 建设 大型电子商务网站怎么创建自己的网站平台
  • 汽车网站建设规划书一个完整的营销策划案范文
  • 可以做免费推广的网站吗海外广告优化师
  • 网站 短链接怎么做搜狗seo软件
  • b2c网站开发背景及必要性市场营销公司有哪些
  • 上海企业网上公示官网手机优化大师官方免费下载
  • 有哪些做外贸免费的网站中国最好的网络营销公司
  • 做电商哪个平台好商丘seo优化
  • 浙江苏省城乡建设厅网站百度竞价入口
  • dreamweaver动态网页制作重庆黄埔seo整站优化
  • 千秋网络是家西安做网站的公司国际域名注册网站
  • 网站模版一样 内容不同侵权吗熊猫关键词工具官网
  • wordpress用户名无效手机关键词排名优化
  • 做销售网站怎么在百度免费推广
  • 开锁都在什么网站做seo智能优化软件
  • 长沙专门做网站公司有哪些台湾新闻最新消息今天
  • vs做网站怎么调试宁波专业seo外包
  • 强大的技术团队网站建设湖南关键词优化品牌价格
  • 攀枝花做网站广告媒体资源平台
  • 民治网站设计圳网站建设公司广州关于进一步优化疫情防控措施
  • 网站同时做竞价和优化可以吗现在最火的推广平台有哪些
  • 各种网站底部图标代码开平网站设计
  • 平面图网站青岛网站建设优化
  • 技术支持 创思佳网站建设网站推广软件费用是多少
  • 如何用asp做视频网站市场调研报告怎么做
  • wordpress图像桂平seo关键词优化
  • 织梦做的网站打开空白全国人大常委会委员长
  • 怎么做网页注册登录教程北京seo主管
  • 网站规划与建设进度百度服务电话
  • 用群晖nas做网站就业seo好还是sem