crud

package
v1.2.21 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: GPL-3.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UserPrivelegiesGrant = "grant"
	UsersPrivilegiesEdit = "edit"
	ActionsPropertyName  = "actions"
)
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:     "need to get result on non-english",
		DefValue: "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),
	}
	ParamsValue = apis.InParam{
		Name:    "value",
		Desc:    "part of polymers name, its Synonyms or Abbreviations",
		PartReq: []string{ParamsID.Name},
		Req:     false,
		Type:    apis.NewTypeInParam(types.String),
	}
	ParamsName = apis.InParam{
		Name:     "name",
		Desc:     "name of search table",
		DefValue: apis.ApisValues(apis.ChildRoutePath),
		Req:      true,
		Type:     apis.NewTypeInParam(types.String),
	}
)

Functions

func AddColumnAndValue added in v1.2.3

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

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) (interface{}, error)

func DecodeDatetimeString

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

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 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, route string) (interface{}, error)

func RenderCreatedResult added in v1.1.10122

func RenderCreatedResult(ctx *fasthttp.RequestCtx, id int64, buf *bytes.Buffer, colSel []string, url string) (interface{}, 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

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 DateRangeMarshal added in v1.2.21

type DateRangeMarshal struct {
	*pgtype.Daterange
}

func (*DateRangeMarshal) GetValue added in v1.2.21

func (d *DateRangeMarshal) GetValue() interface{}

func (*DateRangeMarshal) NewValue added in v1.2.21

func (d *DateRangeMarshal) NewValue() interface{}

func (*DateRangeMarshal) Set added in v1.2.21

func (d *DateRangeMarshal) Set(src interface{}) error

func (*DateRangeMarshal) Value added in v1.2.21

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

type DateTimeString

type DateTimeString time.Time

func (*DateTimeString) CheckParams

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

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) Scan

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

func (*DateTimeString) UnmarshalJSON

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

type DbApiParams added in v1.2.3

type DbApiParams struct {
	apis.InParam
	// contains filtered or unexported fields
}

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) GetValue added in v1.2.21

func (d DtoField) GetValue() any

func (DtoField) NewValue added in v1.2.21

func (d DtoField) NewValue() any

type FormActions

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

type IntervalMarshal added in v1.2.21

type IntervalMarshal struct {
	*pgtype.Interval
}

func (*IntervalMarshal) GetValue added in v1.2.21

func (i *IntervalMarshal) GetValue() interface{}

func (*IntervalMarshal) NewValue added in v1.2.21

func (i *IntervalMarshal) NewValue() interface{}

Jump to

Keyboard shortcuts

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