repo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package repo contains the repository for the database

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotFound = errors.New("not found")

Functions

func ErrorInvalidTable

func ErrorInvalidTable(tableName string) error

func IsTableNotExistError

func IsTableNotExistError(err error) bool

Types

type CreateTableProps

type CreateTableProps struct {
	TableName string           `json:"tableName"`
	Inputs    []database.Input `json:"inputs"`
}

type FormValue

type FormValue struct {
	Value string `json:"value"`
	Type  string `json:"type"`
}

type History

type History struct {
	ID      int       `json:"id"`
	Message string    `json:"message"`
	Time    time.Time `json:"time"`
}

type InsertDataProps

type InsertDataProps struct {
	TableName string
	Values    map[string]FormValue
}

type ListDataCol

type ListDataCol struct {
	IsUnique         bool   `json:"isUnique"`
	Value            any    `json:"value"`
	ColumnName       string `json:"columnName"`
	DataType         string `json:"dataType"`
	InputType        string `json:"inputType"`
	HasAutoIncrement bool   `json:"hasAutoIncrement"`
	HasDefault       bool   `json:"hasDefault"`
}

type ListDataProps

type ListDataProps struct {
	TableName string `json:"tableName"`
	Limit     int    `json:"limit"`
	Offset    int    `json:"offset"`
	Column    string `json:"column"`
	Order     string `json:"order"`
}

type ListDataRow

type ListDataRow []any

type ListTablesRow

type ListTablesRow struct {
	TableSchema string `json:"tableSchema"`
	TableName   string `json:"tableName"`
}

type Querier

type Querier interface {
	ListTables(ctx context.Context) ([]ListTablesRow, error)
	ListCols(ctx context.Context, tableName string) ([]ListDataCol, error)
	ListRows(ctx context.Context, props ListDataProps) (ListDataRow, error)
	InsertRow(ctx context.Context, props InsertDataProps) error
	GetRow(ctx context.Context, tableName, hash string, offset, limit int) ([]any, error)
	GetDriver() string
}

type Queries

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

func New

func New(db *sqlx.DB, driver string, maxItemsPerPage int) *Queries

func (*Queries) CheckTableExitsInDB

func (q *Queries) CheckTableExitsInDB(ctx context.Context, tableName string) error

func (*Queries) CreateHistoryTable

func (q *Queries) CreateHistoryTable(ctx context.Context) error

func (*Queries) CreateTable

func (q *Queries) CreateTable(ctx context.Context, props CreateTableProps) error

func (*Queries) DeleteHistory

func (q *Queries) DeleteHistory(ctx context.Context, id int) error

func (*Queries) DeleteRow

func (q *Queries) DeleteRow(ctx context.Context, props UpdateOrDeleteRowProps) error

func (*Queries) DeleteTable

func (q *Queries) DeleteTable(ctx context.Context, tableName string) error

func (*Queries) GetDriver

func (q *Queries) GetDriver() string

func (*Queries) GetQuotedTableName

func (q *Queries) GetQuotedTableName(tableName string) string

func (*Queries) GetRow

func (q *Queries) GetRow(ctx context.Context, tableName, hash string, offest, limit int) ([]any, error)

func (*Queries) GetRowCount

func (q *Queries) GetRowCount(ctx context.Context, tableName string) (int, error)

func (*Queries) Init

func (q *Queries) Init(ctx context.Context) (err error)

func (*Queries) InsertHistory

func (q *Queries) InsertHistory(ctx context.Context, message string)

func (*Queries) InsertRow

func (q *Queries) InsertRow(ctx context.Context, props InsertDataProps) error

func (*Queries) ListCols

func (q *Queries) ListCols(ctx context.Context, tableName string) ([]ListDataCol, error)

func (*Queries) ListHistory

func (q *Queries) ListHistory(ctx context.Context, limit, offset int) ([]History, error)

func (*Queries) ListRows

func (q *Queries) ListRows(ctx context.Context, props ListDataProps) (ListDataRow, error)

func (*Queries) ListTables

func (q *Queries) ListTables(ctx context.Context) ([]ListTablesRow, error)

func (*Queries) UpdateRow

func (q *Queries) UpdateRow(ctx context.Context, props UpdateOrDeleteRowProps) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sqlx.Tx) *Queries

type QueryParts

type QueryParts struct {
	Columns      string
	Placeholders string
	Args         []any
}

type RowCache

type RowCache struct {
	Max  int
	Keys []string
	Rows map[string][]any
	// contains filtered or unexported fields
}

func NewRowCache

func NewRowCache(max int) *RowCache

func (*RowCache) Delete

func (c *RowCache) Delete(key string)

func (*RowCache) Get

func (c *RowCache) Get(key string) []any

func (*RowCache) Set

func (c *RowCache) Set(key string, row []any)

type UpdateOrDeleteRowProps

type UpdateOrDeleteRowProps struct {
	TableName string
	Values    map[string]FormValue
	Hash      string
	Limit     int
	Offset    int
}

Jump to

Keyboard shortcuts

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