models

package
v0.0.0-...-ce6b2e3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const FULL_MONTH_DATE = "January 02, 2006"
View Source
const HUMAN = "Monday, January 2, 2006 3:04 PM"
View Source
const HUMAN_DATE = "2006-01-02"
View Source
const ISO8601 = "2006-01-02T15:04:05-07:00"

Variables

This section is empty.

Functions

func MakeSlug

func MakeSlug(s string) string

func RemoveMostNonAlphanumeric

func RemoveMostNonAlphanumeric(s string) string

func RemoveNonAlphanumeric

func RemoveNonAlphanumeric(s string) string

func TypeToFlavor

func TypeToFlavor(dt, udt, cd string) string

Types

type BaseModel

type BaseModel struct {
	Item map[string]any
}

func NewBase

func NewBase(item map[string]any) *BaseModel

func (*BaseModel) GetBool

func (b *BaseModel) GetBool(name string) (bool, bool)

func (*BaseModel) GetBytes

func (b *BaseModel) GetBytes(name string) []byte

func (*BaseModel) GetFloat

func (b *BaseModel) GetFloat(name string) float64

func (*BaseModel) GetFloatAsInt

func (b *BaseModel) GetFloatAsInt(name string) int64

func (*BaseModel) GetInt

func (b *BaseModel) GetInt(name string) int64

func (*BaseModel) GetList

func (b *BaseModel) GetList(name string) []any

func (*BaseModel) GetMap

func (b *BaseModel) GetMap(name string) map[string]any

func (*BaseModel) GetSimpleBool

func (b *BaseModel) GetSimpleBool(name string) bool

func (*BaseModel) GetString

func (b *BaseModel) GetString(name string) string

func (*BaseModel) GetStringOk

func (b *BaseModel) GetStringOk(name string) (string, bool)

func (*BaseModel) GetTime

func (b *BaseModel) GetTime(name string) time.Time

type Field

type Field struct {
	Name      string   `json:"name"`
	Flavor    string   `json:"flavor"`
	Index     string   `json:"index"`
	Required  string   `json:"required"`
	Regex     string   `json:"regex"`
	Default   string   `json:"default"`
	Null      string   `json:"null"`
	JsonNames []string `json:"json_names"`
	JsonTypes []string `json:"json_types"`
}

func FindField

func FindField(model *Model, id string) *Field

func (*Field) CommonExclude

func (f *Field) CommonExclude() bool

func (*Field) RandomValue

func (f *Field) RandomValue() any

func (*Field) SaneDefault

func (f *Field) SaneDefault() any

func (*Field) SqlTypeAndDefault

func (f *Field) SqlTypeAndDefault() (string, string)

type Model

type Model struct {
	Name   string   `json:"name"`
	Small  bool     `json:"small"`
	Fields []*Field `json:"fields"`
}

func (*Model) CurlListResponse

func (m *Model) CurlListResponse() string

func (*Model) CurlPostPayload

func (m *Model) CurlPostPayload() string

func (*Model) CurlPutPayload

func (m *Model) CurlPutPayload() string

func (*Model) CurlResponse

func (m *Model) CurlResponse() any

func (*Model) CurlSingleResponse

func (m *Model) CurlSingleResponse() string

func (*Model) CurlSingleResponseNoWrapper

func (m *Model) CurlSingleResponseNoWrapper() string

func (*Model) EnsureIdAndCreatedAt

func (m *Model) EnsureIdAndCreatedAt()

func (*Model) ExampleAlFields

func (m *Model) ExampleAlFields() map[string]any

func (*Model) TableName

func (m *Model) TableName() string

type Path

type Path struct {
	Verb     string `json:"verb"`
	Second   string `json:"second"`
	Third    string `json:"third"`
	Params   string `json:"params"`
	Response string `json:"response"`
}

type Route

type Route struct {
	Root  string  `json:"root"`
	Paths []*Path `json:"paths"`
}

func (*Route) Generate

func (r *Route) Generate(root string) string

Jump to

Keyboard shortcuts

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