package db import ( "context" "fmt" "github.com/jmoiron/sqlx" ) type CoreUpdate struct { ID uint HasUpdate bool CanUpdate bool CouldReachWebsite bool SlowResponse bool Version string Channel string WillDisableModules bool } func (c *CoreUpdate) Insert(tx *sqlx.Tx, data *InsertId[uint]) error { query := fmt.Sprintf(` INSERT INTO core_update (%s, has_update, can_update, could_reach_website, slow_response, version, channel, will_disable_modules) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id`, data.fieldName) args := []any{data.id, c.HasUpdate, c.CanUpdate, c.CouldReachWebsite, c.SlowResponse, c.Version, c.Channel, c.WillDisableModules} err := tx.QueryRowx(query, args...).Scan(&c.ID) if err != nil { return err } return nil } func (c *CoreUpdate) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error { query := fmt.Sprintf(` INSERT INTO core_update (%s, has_update, can_update, could_reach_website, slow_response, version, channel, will_disable_modules) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id`, data.fieldName) args := []any{data.id, c.HasUpdate, c.CanUpdate, c.CouldReachWebsite, c.SlowResponse, c.Version, c.Channel, c.WillDisableModules} err := tx.QueryRowxContext(ctx, query, args...).Scan(&c.ID) if err != nil { return err } return nil } type SystemUpdate struct { ID uint HasUpdate bool Version string }