names

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LintGonicMapper = GonicMapper{
	"API":   true,
	"ASCII": true,
	"CPU":   true,
	"CSS":   true,
	"DNS":   true,
	"EOF":   true,
	"GUID":  true,
	"HTML":  true,
	"HTTP":  true,
	"HTTPS": true,
	"ID":    true,
	"IP":    true,
	"JSON":  true,
	"LHS":   true,
	"QPS":   true,
	"RAM":   true,
	"RHS":   true,
	"RPC":   true,
	"SLA":   true,
	"SMTP":  true,
	"SSH":   true,
	"TLS":   true,
	"TTL":   true,
	"UI":    true,
	"UID":   true,
	"UUID":  true,
	"URI":   true,
	"URL":   true,
	"UTF8":  true,
	"VM":    true,
	"XML":   true,
	"XSRF":  true,
	"XSS":   true,
}

LintGonicMapper is A GonicMapper that contains a list of common initialisms taken from golang/lint

Functions

func GetCollectionName

func GetCollectionName(mapper Mapper, v reflect.Value) string

Types

type CacheMapper

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

func NewCacheMapper

func NewCacheMapper(mapper Mapper) *CacheMapper

func (*CacheMapper) Collection2Obj

func (m *CacheMapper) Collection2Obj(t string) string

func (*CacheMapper) Obj2Collection

func (m *CacheMapper) Obj2Collection(o string) string

type CollectionName

type CollectionName interface {
	CollectionName() string
}

CollectionName interface to define custom collection name

type GonicMapper

type GonicMapper map[string]bool

GonicMapper implements IMapper. It will consider initialisms when mapping names. E.g. id -> ID, user -> User and to table names: UserID -> user_id, MyUID -> my_uid

func (GonicMapper) Collection2Obj

func (mapper GonicMapper) Collection2Obj(name string) string

func (GonicMapper) Obj2Collection

func (mapper GonicMapper) Obj2Collection(name string) string

type Mapper

type Mapper interface {
	Obj2Collection(string) string
	Collection2Obj(string) string
}

Mapper represents a name convertation between struct's fields name and table's column name

type PrefixMapper

type PrefixMapper struct {
	Mapper Mapper
	Prefix string
}

PrefixMapper provides prefix table name support

func NewPrefixMapper

func NewPrefixMapper(mapper Mapper, prefix string) PrefixMapper

func (PrefixMapper) Collection2Obj

func (mapper PrefixMapper) Collection2Obj(name string) string

func (PrefixMapper) Obj2Collection

func (mapper PrefixMapper) Obj2Collection(name string) string

type SameMapper

type SameMapper struct {
}

SameMapper implements IMapper and provides same name between struct and database table

func (SameMapper) Collection2Obj

func (m SameMapper) Collection2Obj(t string) string

func (SameMapper) Obj2Collection

func (m SameMapper) Obj2Collection(o string) string

type SnakeMapper

type SnakeMapper struct {
}

SnakeMapper implements IMapper and provides name transaltion between struct and database table

func (SnakeMapper) Collection2Obj

func (mapper SnakeMapper) Collection2Obj(name string) string

func (SnakeMapper) Obj2Collection

func (mapper SnakeMapper) Obj2Collection(name string) string

type SuffixMapper

type SuffixMapper struct {
	Mapper Mapper
	Suffix string
}

SuffixMapper provides suffix table name support

func NewSuffixMapper

func NewSuffixMapper(mapper Mapper, suffix string) SuffixMapper

func (SuffixMapper) Collection2Obj

func (mapper SuffixMapper) Collection2Obj(name string) string

func (SuffixMapper) Obj2Collection

func (mapper SuffixMapper) Obj2Collection(name string) string

Jump to

Keyboard shortcuts

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