Documentation
¶
Index ¶
Constants ¶
View Source
const MsgFailure = 2
View Source
const MsgSuccess = 1
View Source
const OpsCreate = 8
View Source
const OpsDelete = 64
View Source
const OpsList = 128
View Source
const OpsRead = 16
View Source
const OpsUpdate = 32
View Source
const VERSION = "0.8.1"
Variables ¶
View Source
var ValuesMultipleBitChoice = 1
View Source
var ValuesSingleChoice = 2
Functions ¶
func IsFieldKindSupported ¶
IsFieldKindSupported checks if a field kind is supported by this module
Types ¶
type ContextValue ¶
type ContextValue string
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the main component that gets and saves objects in the database and generates HTTP handler that can be attached to an HTTP server.
func NewController ¶
func NewController(dbConn *sql.DB, tblPrefix string, cfg *ControllerConfig) *Controller
NewController returns new Controller object
func (*Controller) GetORM ¶
func (c *Controller) GetORM() ORM
func (*Controller) Handler ¶
func (c *Controller) Handler(uri string, objFuncs ...func() interface{}) http.Handler
Handler returns an HTTP handler that can be attached to HTTP server. It runs a simple UI that allows managing the data. Each of the func() argument should be funcs that create objects that are meant to be managed in the UI.
type ControllerConfig ¶
type ControllerConfig struct { TagName string PasswordGenerator func(string) string IntFieldValues map[string]IntFieldValues StringFieldValues map[string]StringFieldValues ORM ORM }
type ErrController ¶
ErrController wraps original error that occurred in Err with name of the operation/step that failed, which is in Op field
func (ErrController) Error ¶
func (e ErrController) Error() string
func (ErrController) Unwrap ¶
func (e ErrController) Unwrap() error
type ErrValidation ¶
ErrValidation wraps error occurring during object validation
func (ErrValidation) Error ¶
func (e ErrValidation) Error() string
func (ErrValidation) Unwrap ¶
func (e ErrValidation) Unwrap() error
type HandlerConfig ¶
type IntFieldValues ¶
type ORM ¶
type ORM interface { // RegisterStruct initializes a specific object. ORMs often need to reflect the object to get the fields, build SQL queries etc. // When doing that, certain things such as tags can be inherited from another object. This is in the scenario where there is a root object (eg. Product) that contains all the validation tags and // another struct with less fields should be used as an input for API (eg. Product_WithoutCertainFields). In such case, there is no need to re-define tags such as validation. // Parameter `forceNameForDB` allows forcing another struct name (which later is used for generating table name). // This interface is based on the struct2db module and that module allows some cascade operations (such as delete or update). For this to work, and when certain fields are other structs, ORM must go // deeper and initializes that guys as well. When setting useOnlyRootFromInheritedObj to true, it's being avoided. RegisterStruct(obj interface{}, inheritFromObj interface{}, overwriteExisting bool, forceNameForDB string, useOnlyRootFromInheritedObj bool) error // CreateTables create database tables for struct instances CreateTables(objs ...interface{}) error // DeleteMultiple removes struct items by their ids DeleteMultiple(obj interface{}, filters map[string]interface{}) error // Get fetches data from the database and returns struct instances. Hence, it requires a constructor for the returned objects. Apart from the self-explanatory fields, filters in a format of (field name, any value) // can be added, and each returned object (based on a database row) can be transformed into anything else. Get(newObjFunc func() interface{}, order []string, limit int, offset int, filters map[string]interface{}, rowObjTransformFunc func(interface{}) interface{}) ([]interface{}, error) // GetCount returns number of struct items found in the database GetCount(newObjFunc func() interface{}, filters map[string]interface{}) (int64, error) // Load populates struct instance's field values with database values Load(obj interface{}, id string) error // Save stores (creates or updates) struct instance in the appropriate database table Save(obj interface{}) error // Delete removes struct instance from the database table Delete(obj interface{}) error }
type StringFieldValues ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.