database

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 5 Imported by: 0

README

database

Shared database library for PurgeBot. Wraps a pgx connection pool and exposes typed query functions. One file per table.

Usage

import "github.com/PurgeBot-net/database"

db, err := database.New(ctx, os.Getenv("DATABASE_URL"))
if err != nil {
    log.Fatal(err)
}
defer db.Close()

c, err := db.GetCustomization(ctx, guildID)

Schema

The schema is in schema.sql and is idempotent (CREATE TABLE IF NOT EXISTS). It is mounted into the Postgres container on first start via the docker repo's docker-compose.yml.

Tables
Table Description

| customizations | Per-guild bot name, avatar, and branding toggle (Premium) |

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Customization

type Customization struct {
	GuildID        int64
	BotName        *string
	BotAvatar      *string
	RemoveBranding bool
	UpdatedAt      time.Time
	UpdatedBy      int64
}

type Database

type Database struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, connStr string) (*Database, error)

func (*Database) Close

func (db *Database) Close()

func (*Database) DeleteCustomization added in v0.1.1

func (db *Database) DeleteCustomization(ctx context.Context, guildID int64) error

func (*Database) GetCustomization

func (db *Database) GetCustomization(ctx context.Context, guildID int64) (*Customization, error)

func (*Database) UpsertCustomization

func (db *Database) UpsertCustomization(ctx context.Context, p UpsertCustomizationParams) error

type UpsertCustomizationParams

type UpsertCustomizationParams struct {
	GuildID        int64
	BotName        *string
	BotAvatar      *string
	RemoveBranding bool
	UpdatedBy      int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL