enumdb

package
v1.101.15 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package enumdb allows loading enumeration sets (github.com/Vonage/gosrvlib/pkg/enumcache) from multiple database tables.

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

Example of a 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