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 `traits` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `token_id` bigint(20) unsigned NOT NULL, `key` varchar(256) COLLATE utf8mb4_bin NOT NULL, `value` varchar(256) COLLATE utf8mb4_bin NOT NULL, `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`), KEY `fk_traits_token1_idx` (`token_id`), CONSTRAINT `fk_traits_token1` FOREIGN KEY (`token_id`) REFERENCES `token` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 59, "token_id": 17, "key": "skWGwSxYbGHJTWdhEnmXoTsgE", "value": "wWjTrYWQdKhMSLxkuTLfdkYZi", "created_at": "2095-10-29T23:28:44.604800689+09:00", "updated_at": "2215-12-03T21:21:47.343700838+09:00", "deleted_at": "2047-08-06T18:04:25.485684032+09:00"} Comments ------------------------------------- [ 0] column is set for unsigned [ 1] column is set for unsigned */ // Traits struct is a row record of the traits table in the metarare database type Traits 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] token_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: [] TokenID uint64 `gorm:"column:token_id;type:ubigint;" json:"token_id"` //[ 2] key varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] Key string `gorm:"column:key;type:varchar;size:256;" json:"key"` //[ 3] value varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] Value string `gorm:"column:value;type:varchar;size:256;" json:"value"` //[ 4] 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"` //[ 5] 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"` //[ 6] 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"` } var traitsTableInfo = &TableInfo{ Name: "traits", 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: "token_id", Comment: ``, Notes: `column is set for unsigned`, Nullable: false, DatabaseTypeName: "ubigint", DatabaseTypePretty: "ubigint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "ubigint", ColumnLength: -1, GoFieldName: "TokenID", GoFieldType: "uint64", JSONFieldName: "token_id", ProtobufFieldName: "token_id", ProtobufType: "uint64", ProtobufPos: 2, }, &ColumnInfo{ Index: 2, Name: "key", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "Key", GoFieldType: "string", JSONFieldName: "key", ProtobufFieldName: "key", ProtobufType: "string", ProtobufPos: 3, }, &ColumnInfo{ Index: 3, Name: "value", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "Value", GoFieldType: "string", JSONFieldName: "value", ProtobufFieldName: "value", ProtobufType: "string", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, 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: 5, }, &ColumnInfo{ Index: 5, 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: 6, }, &ColumnInfo{ Index: 6, 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: 7, }, }, } // TableName sets the insert table name for this struct type func (t *Traits) TableName() string { return "traits" } // BeforeSave invoked before saving, return an error if field is not populated. func (t *Traits) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (t *Traits) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (t *Traits) Validate(action Action) error { return nil } // TableInfo return table meta data func (t *Traits) TableInfo() *TableInfo { return traitsTableInfo }