60 lines
2.1 KiB
Go
60 lines
2.1 KiB
Go
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
|
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
|
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
|
|
|
package models
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"go.ipao.vip/gen"
|
|
)
|
|
|
|
const TableNameUserContentAction = "user_content_actions"
|
|
|
|
// UserContentAction mapped from table <user_content_actions>
|
|
type UserContentAction struct {
|
|
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
|
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
|
ContentID int64 `gorm:"column:content_id;type:bigint;not null" json:"content_id"`
|
|
Type string `gorm:"column:type;type:character varying(32);not null" json:"type"`
|
|
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
|
|
}
|
|
|
|
// Quick operations without importing query package
|
|
// Update applies changed fields to the database using the default DB.
|
|
func (m *UserContentAction) Update(ctx context.Context) (gen.ResultInfo, error) {
|
|
return Q.UserContentAction.WithContext(ctx).Updates(m)
|
|
}
|
|
|
|
// Save upserts the model using the default DB.
|
|
func (m *UserContentAction) Save(ctx context.Context) error {
|
|
return Q.UserContentAction.WithContext(ctx).Save(m)
|
|
}
|
|
|
|
// Create inserts the model using the default DB.
|
|
func (m *UserContentAction) Create(ctx context.Context) error {
|
|
return Q.UserContentAction.WithContext(ctx).Create(m)
|
|
}
|
|
|
|
// Delete removes the row represented by the model using the default DB.
|
|
func (m *UserContentAction) Delete(ctx context.Context) (gen.ResultInfo, error) {
|
|
return Q.UserContentAction.WithContext(ctx).Delete(m)
|
|
}
|
|
|
|
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
|
|
func (m *UserContentAction) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
|
|
return Q.UserContentAction.WithContext(ctx).Unscoped().Delete(m)
|
|
}
|
|
|
|
// Reload reloads the model from database by its primary key and overwrites current fields.
|
|
func (m *UserContentAction) Reload(ctx context.Context) error {
|
|
fresh, err := Q.UserContentAction.WithContext(ctx).GetByID(m.ID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*m = *fresh
|
|
return nil
|
|
}
|