enumdb

package
v1.86.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package enumdb allows to load enumeration sets (enumcache) from multiple database tables.

Each enumeration has a numerical ID ("id" on the database table as primary key) and a string name ("name" on the database table as unique string).

Example of MySQL database table that can be used with this package:

CREATE TABLE IF NOT EXISTS `example` (
  `id` SMALLINT UNSIGNED NOT NULL,
  `name` VARCHAR(50) NOT NULL,
  `disabled` TINYINT NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `id_UNIQUE` (`id` ASC),
  UNIQUE INDEX `name_UNIQUE` (`name` ASC))
ENGINE = InnoDB
COMMENT = 'Example enumeration table';

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnumDB

type EnumDB map[string]*enumcache.EnumCache

EnumDB maps each enumeration table name with the corresponding enumeration cache.

func New

func New(ctx context.Context, db *sql.DB, queries EnumTableQuery) (EnumDB, error)

New returns a new enumeration cache for all the tables listed in the queries map.

type EnumTableQuery

type EnumTableQuery map[string]string

EnumTableQuery maps each enumeration table name with the SQL query string used to read the data.

Jump to

Keyboard shortcuts

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