crud

package
v1.2.143 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const PathVersion = "/api/v1"

Variables

View Source
var (
	ParamsID = apis.InParam{
		Name: "id",
		Req:  false,
		Type: apis.NewTypeInParam(types.Int32),
	}
	ParamsLang = apis.InParam{
		Name:     "lang",
		Desc:     "language of response (also may use header 'Accept-Language')",
		DefValue: apis.NewDefValueHeader("Accept-Language", "en"),
		Req:      true,
		Type:     apis.NewTypeInParam(types.String),
	}
	ParamsGetFormActions = apis.InParam{
		Name: "is_get_form_actions",
		Desc: "need to get form actions in response",
		Req:  false,
		Type: apis.NewTypeInParam(types.Bool),
	}
	ParamsLimit = apis.InParam{
		Name:     "limit",
		Desc:     "max count of queries results",
		DefValue: 1000,
		Req:      true,
		Type:     apis.NewTypeInParam(types.Int),
	}
	ParamsOffset = apis.InParam{
		Name: "offset",
		Desc: "offset of queries results",
		Req:  false,
		Type: apis.NewTypeInParam(types.Int),
	}
	ParamsHTML = apis.InParam{
		Name: "html",
		Desc: "need for get result in html instead JSON",
		Req:  false,
		Type: apis.NewTypeInParam(types.Bool),
	}
	ParamsEmail = apis.InParam{
		Name: "email",
		Desc: "email for login",
		Req:  true,
		Type: apis.NewTypeInParam(types.String),
	}
	ParamsPassword = apis.InParam{
		Name: "key",
		Desc: "password or other key word (on future)",
		Req:  true,
		Type: apis.NewTypeInParam(types.String),
	}
	ParamsWhere = apis.InParam{
		Name: "where",
		Desc: "conditions for query ('where' clause)",
		Type: apis.NewTypeInParam(types.String),
	}
	ParamsOrderBy = apis.InParam{
		Name: "order_by",
		Desc: "conditions for sort queries data ('order by' clause)",
		Type: apis.NewTypeInParam(types.String),
	}
	ParamsSelect = apis.InParam{
		Name: "select[]",
		Desc: "list of columns for query ('select' clause)",
		Type: apis.NewSliceTypeInParam(types.String),
	}
	ParamsName = apis.InParam{
		Name:     "name",
		Desc:     "name of parameters. operation, etc.",
		DefValue: apis.ApisValues(apis.ChildRoutePath),
		Req:      true,
		Type:     apis.NewTypeInParam(types.String),
	}
	BasicParams = []apis.InParam{
		ParamsHTML,
		ParamsLang,
	}
	APIQueriesParams = []apis.InParam{
		ParamsGetFormActions,
		ParamsLimit,
		ParamsOffset,
		ParamsWhere,
		ParamsOrderBy,
		ParamsSelect,
		ParamsLang,
		ParamsHTML,
	}
)

Functions

func AddColumnAndValue added in v1.2.3

func AddColumnAndValue(name string, table dbEngine.Table, arg any, buf io.Writer, badParams map[string]string) (string, any)

func ArrayToStrings

func ArrayToStrings(v *pgtype.ArrayType) ([]string, bool)

func BPCharArrayToStrings

func BPCharArrayToStrings(src []pgtype.BPChar) []string

func BlobToURL

func BlobToURL(tableName string, colName string, id int32) string

func CreateErrResult

func CreateErrResult(err error) (any, error)

func DecodeDatetimeString

func DecodeDatetimeString(ptr unsafe.Pointer, iter *jsoniter.Iterator)

func EncodeDateString added in v1.2.90

func EncodeDateString(ptr unsafe.Pointer, stream *jsoniter.Stream)

func GetForeignName

func GetForeignName(ctx *fasthttp.RequestCtx, DB *DB, col Column, val interface{}) interface{}

func GetForeignOptions

func GetForeignOptions(ctx *fasthttp.RequestCtx, DB *dbEngine.DB, colDec *forms.ColumnDecor, id any)

func GetNameAccordingLang

func GetNameAccordingLang(table Table, name string, lang interface{}) string

func GetNameOfTitleColumn

func GetNameOfTitleColumn(table Table, lang interface{}) string

func Int4ArrToStrings

func Int4ArrToStrings(src []pgtype.Int4) []int32

func Int8ArrToStrings

func Int8ArrToStrings(src []pgtype.Int8) []int64

func IsEmptyDateString added in v1.2.90

func IsEmptyDateString(ptr unsafe.Pointer) bool

func NewFileParam added in v1.2.129

func NewFileParam(name, desc string) apis.InParam

NewFileParam create new InParam for handling

func ReadByteA added in v1.2.14

func ReadByteA(fHeaders []*multipart.FileHeader) ([]string, [][]byte, error)

func RenderAcceptedResult added in v1.2.3

func RenderAcceptedResult(ctx *fasthttp.RequestCtx, colSel []string, buf *bytes.Buffer, url string) (any, error)

func RenderAny added in v1.2.101

func RenderAny[T any](ctx *fasthttp.RequestCtx, res T, err error) (any, error)

func RenderArrayResult added in v1.2.101

func RenderArrayResult[T any](ctx *fasthttp.RequestCtx, res []T, err error) (any, error)

func RenderCreatedResult added in v1.1.10122

func RenderCreatedResult(ctx *fasthttp.RequestCtx, id int64, buf *bytes.Buffer, colSel []string, url string) (any, error)

func RoutesFromDB

func RoutesFromDB(ctx context.Context, routeTypes []DbRouteType, tables ...string) apis.ApiRoutes

func TableForm

func TableForm(DB *DB, preRoute string, table Table, priColumns []string) apis.ApiRouteHandler

func TableInsert

func TableInsert(preRoute string, table dbEngine.Table, params []string) apis.ApiRouteHandler

TableInsert insert data of {params} into {table}

func TableSelect

func TableSelect(table dbEngine.Table, params []string) apis.ApiRouteHandler

func TableUpdate

func TableUpdate(preRoute string, table dbEngine.Table, columns, priColumns []string) apis.ApiRouteHandler

TableUpdate update data in {table}

func TextArrayToStrings

func TextArrayToStrings(src []pgtype.Text) []string

func TimeToString

func TimeToString(v time.Time) string

func ToColDev

func ToColDev(ctx *fasthttp.RequestCtx, DB *dbEngine.DB, patternList dbEngine.Table, col dbEngine.Column,
	value any) *forms.ColumnDecor

func ToStandartColumnValueType

func ToStandartColumnValueType(tableName, colName string, id int32, values interface{}) interface{}

func UnknownArrayToStrings

func UnknownArrayToStrings(src []interface{}) []string

func VarcharArrayToStrings

func VarcharArrayToStrings(src []pgtype.Varchar) []string

Types

type DTO added in v1.2.136

type DTO[T any] struct {
	// contains filtered or unexported fields
}

func NewDTO added in v1.2.136

func NewDTO[T any](val T) *DTO[T]

func (*DTO[T]) Format added in v1.2.137

func (d *DTO[T]) Format(s fmt.State, verb rune)

func (*DTO[T]) GetValue added in v1.2.136

func (d *DTO[T]) GetValue() any

func (*DTO[T]) NewValue added in v1.2.136

func (d *DTO[T]) NewValue() any

func (*DTO[T]) String added in v1.2.137

func (d *DTO[T]) String() string

type DTOtype added in v1.2.138

type DTOtype struct {
	Val string
}

func (*DTOtype) Format added in v1.2.138

func (d *DTOtype) Format(s fmt.State, verb rune)

func (*DTOtype) GetValue added in v1.2.138

func (D *DTOtype) GetValue() any

func (*DTOtype) NewValue added in v1.2.138

func (D *DTOtype) NewValue() any

type DateRangeMarshal added in v1.2.21

type DateRangeMarshal struct {
	*pgtype.Daterange
}

func (*DateRangeMarshal) Format added in v1.2.137

func (d *DateRangeMarshal) Format(s fmt.State, verb rune)

Format implement Formatter interface

func (*DateRangeMarshal) GetValue added in v1.2.21

func (d *DateRangeMarshal) GetValue() any

func (*DateRangeMarshal) NewValue added in v1.2.21

func (d *DateRangeMarshal) NewValue() any

func (*DateRangeMarshal) Set added in v1.2.21

func (d *DateRangeMarshal) Set(src any) error

func (*DateRangeMarshal) Value added in v1.2.21

func (d *DateRangeMarshal) Value() (driver.Value, error)

type DateString added in v1.2.86

type DateString time.Time

func (*DateString) Expect added in v1.2.88

func (d *DateString) Expect() string

func (*DateString) Format added in v1.2.88

func (d *DateString) Format(s fmt.State, verb rune)

Format implement Formatter interface

func (*DateString) FormatDoc added in v1.2.137

func (d *DateString) FormatDoc() string

func (*DateString) GetPgxType added in v1.2.138

func (d *DateString) GetPgxType() pgtype.Date

func (*DateString) GetValue added in v1.2.88

func (d *DateString) GetValue() any

func (*DateString) MarshalJSON added in v1.2.89

func (d *DateString) MarshalJSON() ([]byte, error)

func (*DateString) NewValue added in v1.2.88

func (d *DateString) NewValue() any

func (*DateString) RequestType added in v1.2.88

func (d *DateString) RequestType() string

func (*DateString) UnmarshalJSON added in v1.2.86

func (d *DateString) UnmarshalJSON(src []byte) (err error)

type DateTimeString

type DateTimeString time.Time

func (*DateTimeString) CheckParams

func (d *DateTimeString) CheckParams(ctx *fasthttp.RequestCtx, badParams map[string]string) bool

func (*DateTimeString) Expect added in v1.2.22

func (d *DateTimeString) Expect() string

func (*DateTimeString) Format added in v1.2.22

func (d *DateTimeString) Format(s fmt.State, verb rune)

Format implement Formatter interface

func (*DateTimeString) FormatDoc added in v1.2.137

func (d *DateTimeString) FormatDoc() string

func (*DateTimeString) GetPgxType added in v1.2.138

func (d *DateTimeString) GetPgxType() pgtype.Timestamp

func (*DateTimeString) GetValue added in v1.2.21

func (d *DateTimeString) GetValue() any

func (*DateTimeString) MarshalJSON

func (d *DateTimeString) MarshalJSON() ([]byte, error)

func (*DateTimeString) NewValue added in v1.2.21

func (d *DateTimeString) NewValue() any

func (*DateTimeString) RequestType added in v1.2.22

func (d *DateTimeString) RequestType() string

func (*DateTimeString) Scan

func (d *DateTimeString) Scan(src any) error

func (*DateTimeString) UnmarshalJSON

func (d *DateTimeString) UnmarshalJSON(src []byte) (err error)

type DbApiParams added in v1.2.3

type DbApiParams struct {
	apis.InParam
	Col dbEngine.Column
}

func NewDbApiParams added in v1.2.3

func NewDbApiParams(col dbEngine.Column) *DbApiParams

func (*DbApiParams) ConvertDbType added in v1.2.3

func (p *DbApiParams) ConvertDbType(col dbEngine.Column)

type DbRouteType added in v1.2.2

type DbRouteType int
const (
	DbRouteType_Insert DbRouteType = iota
	DbRouteType_Update
	DbRouteType_Select
)

type DtoField added in v1.2.21

type DtoField map[string]any

func (*DtoField) CheckParams added in v1.2.21

func (d *DtoField) CheckParams(ctx *fasthttp.RequestCtx, badParams map[string]string) bool

CheckParams implement CheckDTO interface, put each params into user value on context

func (*DtoField) Expect added in v1.2.22

func (d *DtoField) Expect() string

func (*DtoField) Format added in v1.2.22

func (d *DtoField) Format(s fmt.State, verb rune)

Format implement Formatter interface

func (*DtoField) FormatDoc added in v1.2.137

func (d *DtoField) FormatDoc() string

func (*DtoField) GetValue added in v1.2.21

func (d *DtoField) GetValue() any

func (*DtoField) NewValue added in v1.2.21

func (d *DtoField) NewValue() any

func (*DtoField) RequestType added in v1.2.22

func (d *DtoField) RequestType() string

type DtoFileField added in v1.2.25

type DtoFileField []*multipart.FileHeader

func (*DtoFileField) CheckParams added in v1.2.25

func (d *DtoFileField) CheckParams(ctx *fasthttp.RequestCtx, badParams map[string]string) bool

CheckParams implement CheckDTO interface, put each params into user value on context

func (*DtoFileField) Expect added in v1.2.25

func (d *DtoFileField) Expect() string

func (*DtoFileField) Format added in v1.2.25

func (d *DtoFileField) Format(s fmt.State, verb rune)

Format implement Formatter interface

func (*DtoFileField) FormatDoc added in v1.2.137

func (d *DtoFileField) FormatDoc() string

func (*DtoFileField) GetValue added in v1.2.25

func (d *DtoFileField) GetValue() any

func (*DtoFileField) NewValue added in v1.2.25

func (d *DtoFileField) NewValue() any

func (*DtoFileField) RequestType added in v1.2.25

func (d *DtoFileField) RequestType() string

type FormActions

type FormActions struct {
	Typ string `json:"type"`
	Url string `json:"url"`
}

type InetMarshal added in v1.2.29

type InetMarshal struct {
	*pgtype.Inet
}

func (*InetMarshal) GetValue added in v1.2.29

func (i *InetMarshal) GetValue() any

func (*InetMarshal) NewValue added in v1.2.29

func (i *InetMarshal) NewValue() any

func (*InetMarshal) Set added in v1.2.29

func (i *InetMarshal) Set(src any) error

type IntervalMarshal added in v1.2.21

type IntervalMarshal struct {
	*pgtype.Interval
}

func (*IntervalMarshal) Format added in v1.2.137

func (d *IntervalMarshal) Format(s fmt.State, verb rune)

Format implement Formatter interface

func (*IntervalMarshal) GetValue added in v1.2.21

func (i *IntervalMarshal) GetValue() any

func (*IntervalMarshal) NewValue added in v1.2.21

func (i *IntervalMarshal) NewValue() any

func (*IntervalMarshal) Set added in v1.2.27

func (i *IntervalMarshal) Set(src any) error

type NumrangeMarshal added in v1.2.101

type NumrangeMarshal pgtype.Numrange

func (*NumrangeMarshal) Expect added in v1.2.142

func (n *NumrangeMarshal) Expect() string

func (*NumrangeMarshal) Format added in v1.2.140

func (n *NumrangeMarshal) Format(s fmt.State, verb rune)

Format implement Formatter interface

func (*NumrangeMarshal) FormatDoc added in v1.2.142

func (n *NumrangeMarshal) FormatDoc() string

func (*NumrangeMarshal) GetPgxType added in v1.2.142

func (d *NumrangeMarshal) GetPgxType() pgtype.Numrange

func (*NumrangeMarshal) GetValue added in v1.2.101

func (n *NumrangeMarshal) GetValue() any

func (*NumrangeMarshal) NewValue added in v1.2.101

func (n *NumrangeMarshal) NewValue() any

func (*NumrangeMarshal) RequestType added in v1.2.142

func (n *NumrangeMarshal) RequestType() string

func (*NumrangeMarshal) Set added in v1.2.101

func (n *NumrangeMarshal) Set(src any) error

Jump to

Keyboard shortcuts

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