crudmgr

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OP_C  = "C"
	OP_R  = "R"
	OP_U  = "U"
	OP_D  = "D"
	OP_AA = "AA"
	OP_AD = "AD"
)

Variables

This section is empty.

Functions

func Handle

func Handle[T any](r *mux.Router, db *gorm.DB, a T) error

func MustHandle added in v0.0.6

func MustHandle[T any](r *mux.Router, db *gorm.DB, a T)

func SetDefaultTenant added in v0.0.6

func SetDefaultTenant(t string)

Types

type CrudOpts

type CrudOpts struct {
	Op           string        `json:"op"`           // OP - can be C R U OR D
	Db           string        `json:"db"`           // REsolved by server, nevermind
	Tb           string        `json:"tb"`           // Table name
	Where        []interface{} `json:"where"`        // Where clause - []interface{}{"id =?" , my_var_id}
	ID           interface{}   `json:"id"`           // When dealing w ID required ops, this is mandatory (update, delete)
	Data         interface{}   `json:"data"`         // Object with data to be managed
	Cols         []interface{} `json:"cols"`         // Define cols returned by select
	Associations []string      `json:"associations"` // See gorm docs - https://gorm.io/docs/
	PageSize     int           `json:"pagesize"`     // Offset for selected records
	Page         int           `json:"page"`

	AssociationTable  string `json:"association_table"`
	AssociationFieldA string `json:"association_field_a"`
	AssociationFieldB string `json:"association_field_b"`
	AssociationIDA    uint   `json:"association_id_a"`
	AssociationIDB    uint   `json:"association_id_b"`
	Debug             bool   `json:"debug"`
	AutoPreload       bool   `json:"auto_preload"`
}

type CrudResponse added in v0.0.5

type CrudResponse struct {
	Data         interface{} `json:"data"`
	RowsAffected int64       `json:"rowsaffected"`
}

Jump to

Keyboard shortcuts

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