finish setup data insertion, add world insertion
This commit is contained in:
@@ -14,15 +14,21 @@ type GameOptions struct {
|
||||
Port int
|
||||
}
|
||||
|
||||
func (g *GameOptions) Insert(tx *sqlx.Tx, gameId *InsertId[uint]) error {
|
||||
query := `
|
||||
func (g *GameOptions) Query(data *InsertId[uint]) {
|
||||
data.query = `
|
||||
INSERT INTO featured_content (game_id, language, update_channel, port)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id`
|
||||
}
|
||||
|
||||
args := []any{gameId.id, g.Language, g.UpdateChannel, g.Port}
|
||||
func (g *GameOptions) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||
if data.query == "" {
|
||||
return ErrNoQuery
|
||||
}
|
||||
|
||||
err := tx.QueryRowx(query, args...).Scan(&g.ID)
|
||||
args := []any{data.id, g.Language, g.UpdateChannel, g.Port}
|
||||
|
||||
err := tx.QueryRowx(data.query, args...).Scan(&g.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -30,15 +36,14 @@ func (g *GameOptions) Insert(tx *sqlx.Tx, gameId *InsertId[uint]) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GameOptions) InsertCtx(ctx context.Context, tx *sqlx.Tx, gameId *InsertId[uint]) error {
|
||||
query := `
|
||||
INSERT INTO featured_content (game_id, language, update_channel, port)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id`
|
||||
func (g *GameOptions) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||
if data.query == "" {
|
||||
return ErrNoQuery
|
||||
}
|
||||
|
||||
args := []any{gameId.id, g.Language, g.UpdateChannel, g.Port}
|
||||
args := []any{data.id, g.Language, g.UpdateChannel, g.Port}
|
||||
|
||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&g.ID)
|
||||
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&g.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -71,7 +76,7 @@ func (s *SetupOptions) Query(data *InsertId[uint]) {
|
||||
data.query = `
|
||||
INSERT INTO setup_options (setup_id, css_theme, data_path, hostname, language, local_hostname,
|
||||
update_channel, port, compress_socket, compress_static, fullscreen, hot_reload, proxy_ssl,
|
||||
telemetry, upnp, delete_nedb, no_backups,)
|
||||
telemetry, upnp, delete_nedb, no_backups)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
||||
RETURNING id`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user