package models import ( "database/sql" "time" "github.com/google/uuid" "github.com/guregu/null" "gorm.io/gorm" ) var ( _ = time.Second _ = sql.LevelDefault _ = null.Bool{} _ = uuid.UUID{} ) /* DB Table Details ------------------------------------- CREATE TABLE `user` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `uid` varchar(256) COLLATE utf8mb4_bin NOT NULL COMMENT 'USER_HEX_20\n', `status` enum('stable','blocked','withdrawal') COLLATE utf8mb4_bin NOT NULL DEFAULT 'stable', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `deleted_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 62, "uid": "OvQpucxnuQSdfLYEmxZBaLkPI", "status": "vcBngwSFdGApxBWFhbCsTlDLp", "created_at": "2152-11-01T14:52:49.513042248+09:00", "updated_at": "2305-11-23T17:58:04.134789125+09:00", "deleted_at": "2029-12-30T11:06:58.578732473+09:00"} Comments ------------------------------------- [ 0] column is set for unsigned */ // User_ struct is a row record of the user table in the metarare database type User struct { //[ 0] id ubigint null: false primary: true isArray: false auto: true col: ubigint len: -1 default: [] ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:ubigint;" json:"id"` //[ 1] uid varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] UID string `gorm:"column:uid;type:varchar;size:256;" json:"uid"` // USER_HEX_20\n //[ 2] status char(10) null: false primary: false isArray: false auto: false col: char len: 10 default: [stable] Status string `gorm:"column:status;type:char;size:10;default:stable;" json:"status"` //[ 3] created_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP] CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"created_at"` //[ 4] updated_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP] UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"updated_at"` //[ 5] deleted_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: [] DeletedAt null.Time `gorm:"column:deleted_at;type:timestamp;" json:"deleted_at"` UserProfile UserProfile UserWallet UserWallet } var userTableInfo = &TableInfo{ Name: "user", Columns: []*ColumnInfo{ &ColumnInfo{ Index: 0, Name: "id", Comment: ``, Notes: `column is set for unsigned`, Nullable: false, DatabaseTypeName: "ubigint", DatabaseTypePretty: "ubigint", IsPrimaryKey: true, IsAutoIncrement: true, IsArray: false, ColumnType: "ubigint", ColumnLength: -1, GoFieldName: "ID", GoFieldType: "uint64", JSONFieldName: "id", ProtobufFieldName: "id", ProtobufType: "uint64", ProtobufPos: 1, }, &ColumnInfo{ Index: 1, Name: "uid", Comment: `USER_HEX_20\n`, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "UID", GoFieldType: "string", JSONFieldName: "uid", ProtobufFieldName: "uid", ProtobufType: "string", ProtobufPos: 2, }, &ColumnInfo{ Index: 2, Name: "status", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "char", DatabaseTypePretty: "char(10)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 10, GoFieldName: "Status", GoFieldType: "string", JSONFieldName: "status", ProtobufFieldName: "status", ProtobufType: "string", ProtobufPos: 3, }, &ColumnInfo{ Index: 3, Name: "created_at", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "timestamp", DatabaseTypePretty: "timestamp", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "timestamp", ColumnLength: -1, GoFieldName: "CreatedAt", GoFieldType: "time.Time", JSONFieldName: "created_at", ProtobufFieldName: "created_at", ProtobufType: "uint64", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, Name: "updated_at", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "timestamp", DatabaseTypePretty: "timestamp", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "timestamp", ColumnLength: -1, GoFieldName: "UpdatedAt", GoFieldType: "time.Time", JSONFieldName: "updated_at", ProtobufFieldName: "updated_at", ProtobufType: "uint64", ProtobufPos: 5, }, &ColumnInfo{ Index: 5, Name: "deleted_at", Comment: ``, Notes: ``, Nullable: true, DatabaseTypeName: "timestamp", DatabaseTypePretty: "timestamp", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "timestamp", ColumnLength: -1, GoFieldName: "DeletedAt", GoFieldType: "null.Time", JSONFieldName: "deleted_at", ProtobufFieldName: "deleted_at", ProtobufType: "uint64", ProtobufPos: 6, }, }, } // TableName sets the insert table name for this struct type func (u *User) TableName() string { return "user" } // BeforeSave invoked before saving, return an error if field is not populated. func (u *User) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (u *User) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (u *User) Validate(action Action) error { return nil } // TableInfo return table meta data func (u *User) TableInfo() *TableInfo { return userTableInfo }