common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelToSnake

func CamelToSnake(s string) string

CamelToSnake converts camelCase to snake_case

func GetFKeyName

func GetFKeyName(i interface{}, ft, rt, ff, rf string) (string, error)

GetFKeyName can be used to determine the foreign-key name based on a set of input fields. Note that this function does not guarantee or check for the existence of the foreign-key; it simply provides the name that would have been used for the given parameter values. i: Model{} ft: From Table rt: Reference Table ff: From Field rf: Reference Field

func GetTableName

func GetTableName(i interface{}) string

GetTableName determines the db table-name based on interface{} i

Types

type FieldDef

type FieldDef struct {
	FName       string
	FType       string
	GoName      string
	GoType      string
	UnderGoType string // underlying go-type (strip *)
	NoDB        bool
	SqacPairs   []SqacPair
}

FieldDef holds field-names and a slice of their db attributes

func TagReader

func TagReader(i interface{}, t reflect.Type) (fd []FieldDef, err error)

TagReader reads the `db:`, `sqac:` and (maybe)`sql:` tags and returns an array of type FieldDef.

type SqacPair

type SqacPair struct {
	Name  string
	Value string
}

SqacPair holds name-value-pairs for db field attributes

Jump to

Keyboard shortcuts

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