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 `token` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `collection_id` bigint(20) unsigned NOT NULL, `name` varchar(128) COLLATE utf8mb4_bin NOT NULL, `description` text COLLATE utf8mb4_bin NOT NULL, `type` enum('erc721','erc1155') COLLATE utf8mb4_bin NOT NULL DEFAULT 'erc721', `total_count` int(10) unsigned DEFAULT NULL, `index` int(10) unsigned DEFAULT NULL, `content_url` varchar(256) COLLATE utf8mb4_bin NOT NULL, `assets_image_url` varchar(256) COLLATE utf8mb4_bin NOT NULL, `lastest_price` double DEFAULT NULL, `royalties` int(10) unsigned NOT NULL DEFAULT '0', `creator_address` 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, `lastest_currency` enum('eth','mr','mf') COLLATE utf8mb4_bin DEFAULT NULL, `owner_address` varchar(256) COLLATE utf8mb4_bin NOT NULL, `like_count` int(10) unsigned NOT NULL DEFAULT '0', `uid` varchar(256) COLLATE utf8mb4_bin NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `fk_token_collection1_idx` (`collection_id`), CONSTRAINT `fk_token_collection1` FOREIGN KEY (`collection_id`) REFERENCES `collection` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 50, "collection_id": 6, "name": "HdhEKCwKryeydaXVThoFxpKiG", "description": "PAJBLrfkkwOhXBJBnCApUiDwN", "type": "vBtnugXUabKKxTlHbjaCCkqyg", "total_count": 21, "index": 67, "content_url": "fsiXuUmoxMfMCjlYqJKmDPUEx", "assets_image_url": "syfFdawPpltvDvlhqLsqjWHHj", "lastest_price": 0.08218025651900168, "royalties": 1, "creator_address": "uXxWHgBjuXHElZnBreaBwbOur", "created_at": "2264-08-09T16:32:26.762845536+09:00", "updated_at": "2193-05-17T21:18:15.393715445+09:00", "deleted_at": "2166-08-03T12:57:01.298461162+09:00", "lastest_currency": "KtayejtZlmiAcTJlPESQqYFDQ", "owner_address": "oOXTparpmNBArVulnPTetflql", "like_count": 86, "uid": "kkAXiJeKcDBJEbyXuhHuvcwPj"} Comments ------------------------------------- [ 0] column is set for unsigned [ 1] column is set for unsigned [ 5] column is set for unsigned [ 6] column is set for unsigned [10] column is set for unsigned [17] column is set for unsigned */ // Token struct is a row record of the token table in the metarare database type Token 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] collection_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: [] CollectionID uint64 `gorm:"column:collection_id;type:ubigint;" json:"collection_id"` //[ 2] name varchar(128) null: false primary: false isArray: false auto: false col: varchar len: 128 default: [] Name string `gorm:"column:name;type:varchar;size:128;" json:"name"` //[ 3] description text(65535) null: false primary: false isArray: false auto: false col: text len: 65535 default: [] Description string `gorm:"column:description;type:text;size:65535;" json:"description"` //[ 4] type char(7) null: false primary: false isArray: false auto: false col: char len: 7 default: [erc721] Type string `gorm:"column:type;type:char;size:7;default:erc721;" json:"type"` //[ 5] total_count uint null: true primary: false isArray: false auto: false col: uint len: -1 default: [] TotalCount null.Int `gorm:"column:total_count;type:uint;" json:"total_count"` //[ 6] index uint null: true primary: false isArray: false auto: false col: uint len: -1 default: [] Index null.Int `gorm:"column:index;type:uint;" json:"index"` //[ 7] content_url varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] ContentURL string `gorm:"column:content_url;type:varchar;size:256;" json:"content_url"` //[ 8] assets_image_url varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] AssetsImageURL string `gorm:"column:assets_image_url;type:varchar;size:256;" json:"assets_image_url"` //[ 9] lastest_price double null: true primary: false isArray: false auto: false col: double len: -1 default: [] LastestPrice null.Float `gorm:"column:lastest_price;type:double;" json:"lastest_price"` //[10] royalties uint null: false primary: false isArray: false auto: false col: uint len: -1 default: [0] Royalties uint32 `gorm:"column:royalties;type:uint;default:0;" json:"royalties"` //[11] creator_address varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] CreatorAddress string `gorm:"column:creator_address;type:varchar;size:256;" json:"creator_address"` //[12] 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"` //[13] 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"` //[14] 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"` //[15] lastest_currency char(3) null: true primary: false isArray: false auto: false col: char len: 3 default: [] LastestCurrency null.String `gorm:"column:lastest_currency;type:char;size:3;" json:"lastest_currency"` //[16] owner_address varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] OwnerAddress string `gorm:"column:owner_address;type:varchar;size:256;" json:"owner_address"` //[17] like_count uint null: false primary: false isArray: false auto: false col: uint len: -1 default: [0] LikeCount uint32 `gorm:"column:like_count;type:uint;default:0;" json:"like_count"` //[18] 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"` } var tokenTableInfo = &TableInfo{ Name: "token", 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: "collection_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: "CollectionID", GoFieldType: "uint64", JSONFieldName: "collection_id", ProtobufFieldName: "collection_id", ProtobufType: "uint64", ProtobufPos: 2, }, &ColumnInfo{ Index: 2, Name: "name", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(128)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 128, GoFieldName: "Name", GoFieldType: "string", JSONFieldName: "name", ProtobufFieldName: "name", ProtobufType: "string", ProtobufPos: 3, }, &ColumnInfo{ Index: 3, Name: "description", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "text", DatabaseTypePretty: "text(65535)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "text", ColumnLength: 65535, GoFieldName: "Description", GoFieldType: "string", JSONFieldName: "description", ProtobufFieldName: "description", ProtobufType: "string", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, Name: "type", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "char", DatabaseTypePretty: "char(7)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 7, GoFieldName: "Type", GoFieldType: "string", JSONFieldName: "type", ProtobufFieldName: "type", ProtobufType: "string", ProtobufPos: 5, }, &ColumnInfo{ Index: 5, Name: "total_count", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "uint", DatabaseTypePretty: "uint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "uint", ColumnLength: -1, GoFieldName: "TotalCount", GoFieldType: "null.Int", JSONFieldName: "total_count", ProtobufFieldName: "total_count", ProtobufType: "uint32", ProtobufPos: 6, }, &ColumnInfo{ Index: 6, Name: "index", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "uint", DatabaseTypePretty: "uint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "uint", ColumnLength: -1, GoFieldName: "Index", GoFieldType: "null.Int", JSONFieldName: "index", ProtobufFieldName: "index", ProtobufType: "uint32", ProtobufPos: 7, }, &ColumnInfo{ Index: 7, Name: "content_url", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "ContentURL", GoFieldType: "string", JSONFieldName: "content_url", ProtobufFieldName: "content_url", ProtobufType: "string", ProtobufPos: 8, }, &ColumnInfo{ Index: 8, Name: "assets_image_url", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "AssetsImageURL", GoFieldType: "string", JSONFieldName: "assets_image_url", ProtobufFieldName: "assets_image_url", ProtobufType: "string", ProtobufPos: 9, }, &ColumnInfo{ Index: 9, Name: "lastest_price", Comment: ``, Notes: ``, Nullable: true, DatabaseTypeName: "double", DatabaseTypePretty: "double", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "double", ColumnLength: -1, GoFieldName: "LastestPrice", GoFieldType: "null.Float", JSONFieldName: "lastest_price", ProtobufFieldName: "lastest_price", ProtobufType: "float", ProtobufPos: 10, }, &ColumnInfo{ Index: 10, Name: "royalties", Comment: ``, Notes: `column is set for unsigned`, Nullable: false, DatabaseTypeName: "uint", DatabaseTypePretty: "uint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "uint", ColumnLength: -1, GoFieldName: "Royalties", GoFieldType: "uint32", JSONFieldName: "royalties", ProtobufFieldName: "royalties", ProtobufType: "uint32", ProtobufPos: 11, }, &ColumnInfo{ Index: 11, Name: "creator_address", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "CreatorAddress", GoFieldType: "string", JSONFieldName: "creator_address", ProtobufFieldName: "creator_address", ProtobufType: "string", ProtobufPos: 12, }, &ColumnInfo{ Index: 12, 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: 13, }, &ColumnInfo{ Index: 13, 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: 14, }, &ColumnInfo{ Index: 14, 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: 15, }, &ColumnInfo{ Index: 15, Name: "lastest_currency", Comment: ``, Notes: ``, Nullable: true, DatabaseTypeName: "char", DatabaseTypePretty: "char(3)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 3, GoFieldName: "LastestCurrency", GoFieldType: "null.String", JSONFieldName: "lastest_currency", ProtobufFieldName: "lastest_currency", ProtobufType: "string", ProtobufPos: 16, }, &ColumnInfo{ Index: 16, Name: "owner_address", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "OwnerAddress", GoFieldType: "string", JSONFieldName: "owner_address", ProtobufFieldName: "owner_address", ProtobufType: "string", ProtobufPos: 17, }, &ColumnInfo{ Index: 17, Name: "like_count", Comment: ``, Notes: `column is set for unsigned`, Nullable: false, DatabaseTypeName: "uint", DatabaseTypePretty: "uint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "uint", ColumnLength: -1, GoFieldName: "LikeCount", GoFieldType: "uint32", JSONFieldName: "like_count", ProtobufFieldName: "like_count", ProtobufType: "uint32", ProtobufPos: 18, }, &ColumnInfo{ Index: 18, Name: "uid", Comment: ``, 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: 19, }, }, } // TableName sets the insert table name for this struct type func (t *Token) TableName() string { return "token" } // BeforeSave invoked before saving, return an error if field is not populated. func (t *Token) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (t *Token) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (t *Token) Validate(action Action) error { return nil } // TableInfo return table meta data func (t *Token) TableInfo() *TableInfo { return tokenTableInfo }