Documentation
¶
Index ¶
- Constants
- func ObjFieldInterfaces(obj interface{}, includeID bool) []interface{}
- func ObjFieldValue(obj interface{}, fieldName string) interface{}
- func ObjIDInterface(obj interface{}) interface{}
- func ObjIDValue(obj interface{}) int64
- func SetObjCreated(obj interface{}, at int64, by int64)
- func SetObjModified(obj interface{}, at int64, by int64)
- func SetObjStringField(obj interface{}, passField, hashField string)
- func Validate(obj interface{}, restrictFields map[string]bool, tagName string) (bool, map[string]int, error)
- func ValidateFilters(obj interface{}, filters *sqlfilters.Filters, tagName string) error
- func ZeroObjFields(obj interface{})
- type CRUD
- func (c *CRUD) CreateTable(ctx context.Context, obj interface{}) error
- func (c *CRUD) Delete(ctx context.Context, obj interface{}, options DeleteOptions) error
- func (c *CRUD) DeleteMultiple(ctx context.Context, obj interface{}, options DeleteMultipleOptions) error
- func (c *CRUD) DropTable(ctx context.Context, obj interface{}) error
- func (c *CRUD) Get(ctx context.Context, newObjFunc func() interface{}, options GetOptions) ([]interface{}, error)
- func (c *CRUD) GetCount(ctx context.Context, obj interface{}, options GetCountOptions) (int64, error)
- func (c *CRUD) Load(ctx context.Context, obj interface{}, id string, options LoadOptions) error
- func (c *CRUD) Save(ctx context.Context, obj interface{}, options SaveOptions) error
- func (c *CRUD) SetFlag(flag int64)
- func (c *CRUD) UpdateMultiple(ctx context.Context, obj interface{}, fieldsToUpdate map[string]interface{}, ...) error
- type CRUDError
- type DeleteMultipleOptions
- type DeleteOptions
- type GetCountOptions
- type GetOptions
- type LoadOptions
- type Options
- type SaveOptions
- type UniqError
- type UpdateMultipleOptions
- type ValidationError
Constants ¶
const (
GetCountOnUniq = 1
)
const (
IDField = "ID"
)
Variables ¶
This section is empty.
Functions ¶
func ObjFieldInterfaces ¶
func ObjFieldInterfaces(obj interface{}, includeID bool) []interface{}
ObjFieldInterfaces returns a list of interfaces to object's fields Argument includeID tells it to include or omit the ID field
func ObjFieldValue ¶
func ObjFieldValue(obj interface{}, fieldName string) interface{}
func ObjIDInterface ¶
func ObjIDInterface(obj interface{}) interface{}
func ObjIDValue ¶
func ObjIDValue(obj interface{}) int64
func SetObjCreated ¶
func SetObjModified ¶
func SetObjStringField ¶
func SetObjStringField(obj interface{}, passField, hashField string)
func ValidateFilters ¶
func ValidateFilters(obj interface{}, filters *sqlfilters.Filters, tagName string) error
func ZeroObjFields ¶
func ZeroObjFields(obj interface{})
Types ¶
type CRUD ¶
type CRUD struct {
// contains filtered or unexported fields
}
func (*CRUD) CreateTable ¶
CreateTable creates a database table for the specified object.
func (*CRUD) Delete ¶
func (c *CRUD) Delete(ctx context.Context, obj interface{}, options DeleteOptions) error
Delete removes an object from the database table only when ID field is set (greater than 0). Once deleted from the DB, all field values are zeroed
func (*CRUD) DeleteMultiple ¶
func (c *CRUD) DeleteMultiple(ctx context.Context, obj interface{}, options DeleteMultipleOptions) error
DeleteMultiple removes objects from the database based on specified filters
func (*CRUD) Get ¶
func (c *CRUD) Get(ctx context.Context, newObjFunc func() interface{}, options GetOptions) ([]interface{}, error)
func (*CRUD) GetCount ¶
func (c *CRUD) GetCount(ctx context.Context, obj interface{}, options GetCountOptions) (int64, error)
GetCount runs a 'SELECT COUNT(*)' query on the database with specified filters, order, limit and offset and returns count of rows
func (*CRUD) Save ¶
func (c *CRUD) Save(ctx context.Context, obj interface{}, options SaveOptions) error
Save takes an object, validates its field values, and saves it in the database. If ID is not present, then an INSERT will be performed. If ID is set, then an "upsert" is performed.
func (*CRUD) UpdateMultiple ¶
type DeleteMultipleOptions ¶
type DeleteMultipleOptions struct {
Filters *sqlfilters.Filters
CascadeDeleteDepth int8
}
type DeleteOptions ¶
type DeleteOptions struct{}
type GetCountOptions ¶
type GetCountOptions struct {
Filters *sqlfilters.Filters
ConvertFiltersFromString bool
}
type GetOptions ¶
type LoadOptions ¶
type LoadOptions struct {
Unused bool
}
type SaveOptions ¶
type UpdateMultipleOptions ¶
type UpdateMultipleOptions struct {
Filters *sqlfilters.Filters
ConvertValuesFromString bool
}
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string