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_like` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `is_like` tinyint(4) NOT NULL DEFAULT '0', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `deleted_at` timestamp NULL DEFAULT NULL, `user_id` bigint(20) unsigned NOT NULL, `token_id` bigint(20) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `fk_user_like_user1_idx` (`user_id`), KEY `fk_user_like_token1_idx` (`token_id`), CONSTRAINT `fk_user_like_token1` FOREIGN KEY (`token_id`) REFERENCES `token` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_user_like_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 21, "is_like": 0, "created_at": "2293-03-02T09:26:56.685703114+09:00", "updated_at": "2294-11-15T21:28:28.813340144+09:00", "deleted_at": "2202-11-01T08:41:19.156484638+09:00", "user_id": 44, "token_id": 79} Comments ------------------------------------- [ 0] column is set for unsigned [ 5] column is set for unsigned [ 6] column is set for unsigned */ // UserLike struct is a row record of the user_like table in the metarare database type UserLike 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] is_like tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0] IsLike int32 `gorm:"column:is_like;type:tinyint;default:0;" json:"is_like"` //[ 2] 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"` //[ 3] 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"` //[ 4] 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"` //[ 5] user_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: [] UserID uint64 `gorm:"column:user_id;type:ubigint;" json:"user_id"` //[ 6] 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"` User User Token Token } var user_likeTableInfo = &TableInfo{ Name: "user_like", 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: "is_like", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "tinyint", DatabaseTypePretty: "tinyint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "tinyint", ColumnLength: -1, GoFieldName: "IsLike", GoFieldType: "int32", JSONFieldName: "is_like", ProtobufFieldName: "is_like", ProtobufType: "int32", ProtobufPos: 2, }, &ColumnInfo{ Index: 2, 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: 3, }, &ColumnInfo{ Index: 3, 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: 4, }, &ColumnInfo{ Index: 4, 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: 5, }, &ColumnInfo{ Index: 5, Name: "user_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: "UserID", GoFieldType: "uint64", JSONFieldName: "user_id", ProtobufFieldName: "user_id", ProtobufType: "uint64", ProtobufPos: 6, }, &ColumnInfo{ Index: 6, 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: 7, }, }, } // TableName sets the insert table name for this struct type func (u *UserLike) TableName() string { return "user_like" } // BeforeSave invoked before saving, return an error if field is not populated. func (u *UserLike) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (u *UserLike) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (u *UserLike) Validate(action Action) error { return nil } // TableInfo return table meta data func (u *UserLike) TableInfo() *TableInfo { return user_likeTableInfo }