mcdbcrud

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 17 Imported by: 0

README

mcdbcrud | github.com/abbeymart/mcdbcrud

  • CRUD operations package for RDBMS in Go - PostgreSQL [and MySQL and SQLite - work-in-progress]
  • See the test files for different test cases / scenarios and usage

Documentation

Index

Constants

View Source
const (
	CreateLog = "create"
	UpdateLog = "update"
	ReadLog   = "read"
	GetLog    = "get"
	DeleteLog = "delete"
	RemoveLog = "remove"
	LoginLog  = "login"
	LogoutLog = "logout"
)

constants LogTypes

View Source
const (
	CreateTask  = "create"
	InsertTask  = "insert"
	UpdateTask  = "update"
	ReadTask    = "read"
	DeleteTask  = "delete"
	RemoveTask  = "remove"
	LoginTask   = "login"
	LogoutTask  = "logout"
	SystemTask  = "system"
	AppTask     = "app"
	UnknownTask = "unknown"
)
View Source
const (
	CrudQueryFieldCustom  = "custom"
	CrudQueryFieldDefault = "underscore"
)
View Source
const AuditTable = "audits"
View Source
const DeleteAllTable = "audits_delete_all"
View Source
const DeleteTable = "audits_delete"
View Source
const GetTable = "audits_get"
View Source
const UpdateTable = "audits_update"
View Source
const UserId = "c85509ac-7373-464d-b667-425bb59b5738" // TODO: review/update

Variables

View Source
var AuditCreateActionParams = ActionParamsType{
	AuditCreateRec1,
	AuditCreateRec2,
}
View Source
var AuditCreateRec1 = ActionParamType{
	"tableName":  "audits",
	"logAt":      time.Now(),
	"logBy":      UserId,
	"logRecords": string(LogRecs),
	"logType":    CreateTask,
}
View Source
var AuditCreateRec2 = ActionParamType{
	"tableName":  "audits",
	"logAt":      time.Now(),
	"logBy":      UserId,
	"logRecords": string(LogRecs2),
	"logType":    CreateTask,
}
View Source
var AuditUpdateActionParams = ActionParamsType{
	AuditUpdateRec1,
	AuditUpdateRec2,
}
View Source
var AuditUpdateRec1 = ActionParamType{
	"id":            "c1c3f614-b10d-40a4-9269-4e03f5fcf55e",
	"tableName":     "todos",
	"logAt":         time.Now(),
	"logBy":         UserId,
	"logRecords":    string(LogRecs),
	"newLogRecords": string(NewLogRecs),
	"logType":       UpdateTask,
}
View Source
var AuditUpdateRec2 = ActionParamType{
	"id":            "003c1422-c7cb-476f-b96f-9c8028e04a14",
	"tableName":     "todos",
	"logAt":         time.Now(),
	"logBy":         UserId,
	"logRecords":    string(LogRecs2),
	"newLogRecords": string(NewLogRecs2),
	"logType":       UpdateTask,
}
View Source
var AuditUpdateRecordById = ActionParamType{
	"id":            "b126f4c0-9bad-4242-bec1-4c4ab74ae481",
	"tableName":     "groups",
	"logAt":         time.Now(),
	"logBy":         UserId,
	"logRecords":    string(LogRecs),
	"newLogRecords": string(NewLogRecs),
	"logType":       DeleteTask,
}
View Source
var AuditUpdateRecordByParam = ActionParamType{
	"id":            "f380f132-422f-4cd4-82c1-07b4caf35da0",
	"tableName":     "contacts",
	"logAt":         time.Now(),
	"logBy":         UserId,
	"logRecords":    string(LogRecs),
	"newLogRecords": string(NewLogRecs),
	"logType":       UpdateTask,
}
View Source
var CrudParamOptions = CrudOptionsType{
	CheckAccess:   false,
	AuditTable:    "audits",
	UserTable:     "users",
	ProfileTable:  "profiles",
	ServiceTable:  "services",
	AccessTable:   "accesses",
	VerifyTable:   "verify_users",
	RoleTable:     "roles",
	LogCrud:       false,
	LogCreate:     false,
	LogUpdate:     false,
	LogDelete:     false,
	LogRead:       false,
	LogLogin:      false,
	LogLogout:     false,
	MaxQueryLimit: 100000,
	MsgFrom:       "support@mconnect.biz",
}
View Source
var DeleteAuditById = "99f0f869-3c84-4a5e-83ac-3b9f893dcd60"
View Source
var DeleteAuditByIds = []string{
	"9e9f7733-7653-4069-9f42-dc157768a960",
	"35304003-567f-4e25-9f1d-6483760db621",
	"d0a1445e-f12f-4d45-98e5-22689dec48e5",
	"39774322-9be5-4b43-9d6e-e2ba514e0f43",
}
View Source
var DeleteAuditByParams = QueryParamType{
	"logType": "read",
}
View Source
var GetAuditById = "7461ae6c-96e0-4b4f-974b-9a0a7f91e016"
View Source
var GetAuditByIds = []string{"7461ae6c-96e0-4b4f-974b-9a0a7f91e016", "aa9ba999-b138-414b-be66-9f0264e50f4a"}
View Source
var GetAuditByParams = QueryParamType{
	"logType": "create",
}
View Source
var LogRecords = ActionParamType{
	"name":     "Abi",
	"desc":     "Testing only",
	"url":      "localhost:9000",
	"priority": 100,
	"cost":     1000.00,
}
View Source
var LogRecords2 = ActionParamType{
	"name":     "Ola",
	"desc":     "Testing only - 2",
	"url":      "localhost:9000",
	"priority": 1,
	"cost":     10000.00,
}
View Source
var LogRecs, _ = json.Marshal(LogRecords)
View Source
var LogRecs2, _ = json.Marshal(LogRecords2)
View Source
var NewLogRecords = ActionParamType{
	"name":     "Abi Akindele",
	"desc":     "Testing only - updated",
	"url":      "localhost:9900",
	"priority": 1,
	"cost":     2000.00,
}
View Source
var NewLogRecords2 = ActionParamType{
	"name":     "Ola",
	"desc":     "Testing only - 2 - updated",
	"url":      "localhost:9000",
	"priority": 1,
	"cost":     20000.00,
}
View Source
var NewLogRecs, _ = json.Marshal(NewLogRecords)
View Source
var NewLogRecs2, _ = json.Marshal(NewLogRecords2)
View Source
var TestUserInfo = UserInfoType{
	UserId:    "c85509ac-7373-464d-b667-425bb59b5738",
	LoginName: "abbeymart",
	Email:     "abbeya1@yahoo.com",
	Language:  "en-US",
	Firstname: "Abi",
	Lastname:  "Akindele",
	Token:     "",
	Expire:    0,
	RoleId:    "",
}
View Source
var UpdateAuditById = "98bb024e-2b22-42b4-b379-7099166ad1c9"
View Source
var UpdateAuditByIds = []string{
	"c158c19f-e396-4625-96ee-d054ef4f40a1",
	"e34b10f9-6320-4573-96cc-2cd8c69c9a89",
	"9b9acf43-9008-4261-9528-39f47f261adf",
}
View Source
var UpdateAuditByParams = QueryParamType{
	"logType": "read",
}

Functions

func ArrayIntContains

func ArrayIntContains(arr []int, val int) bool

ArrayIntContains check if a slice of int contains/includes an int value

func ArrayMapToMapUnderscore

func ArrayMapToMapUnderscore(rec interface{}) ([]map[string]interface{}, error)

ArrayMapToMapUnderscore converts []map-fields to underscore

func ArrayMapToStruct

func ArrayMapToStruct(actParams ActionParamsType, recs interface{}) (interface{}, error)

ArrayMapToStruct converts []map/actParams to []struct/model-type

func ArrayStringContains

func ArrayStringContains(arr []string, val string) bool

ArrayStringContains check if a slice of string contains/includes a string value

func ArrayToSQLStringValues

func ArrayToSQLStringValues(arr []string) string

ArrayToSQLStringValues transforms a slice of string to SQL-string-formatted-values

func CheckTaskType

func CheckTaskType(params CrudParamsType) string

CheckTaskType determine/set task type based on the actionParams

func ComputeTaskDuration

func ComputeTaskDuration(start time.Time, end time.Time) int64

ComputeTaskDuration computes the task interval in microseconds

func ConvertByteSliceToBase64Str

func ConvertByteSliceToBase64Str(fileContent []byte) string

func ConvertJsonBase64StringToMap

func ConvertJsonBase64StringToMap(base64Str interface{}) (map[string]interface{}, error)

ConvertJsonBase64StringToMap converts the db-json-string-value to the map-type

func ConvertJsonBase64StringToTypeValue

func ConvertJsonBase64StringToTypeValue(base64Str interface{}, typePointer interface{}) (interface{}, error)

ConvertJsonBase64StringToTypeValue converts the db-json-string-value to the base-type

func ConvertJsonStringToMapValue

func ConvertJsonStringToMapValue(jsonStr string) (map[string]interface{}, error)

ConvertJsonStringToMapValue converts the db-json-string-value to the map-type

func ConvertJsonStringToTypeValue

func ConvertJsonStringToTypeValue(jsonStr string, typePointer interface{}) (interface{}, error)

ConvertJsonStringToTypeValue converts the db-json-string-value to the base-type

func ConvertStringToBase64Str

func ConvertStringToBase64Str(fileContent string) string

func GetParamsMessage

func GetParamsMessage(msgObject MessageObject) mcresponse.ResponseMessage

GetParamsMessage compose the message-object into mcresponse.ResponseMessage

func JsonToStruct

func JsonToStruct(jsonRec []byte, rec interface{}) error

JsonToStruct converts json inputs to equivalent struct data type specification rec must be a pointer to a type matching the jsonRec

func MapToMapCamelCase

func MapToMapCamelCase(rec interface{}, sep string) (map[string]interface{}, error)

MapToMapCamelCase converts map underscore-fields to camelCase-fields

func MapToMapUnderscore

func MapToMapUnderscore(rec interface{}) (map[string]interface{}, error)

MapToMapUnderscore converts map camelCase-fields to underscore-fields

func MapToStruct

func MapToStruct(mapRecord map[string]interface{}, rec interface{}) (interface{}, error)

MapToStruct converts map to struct

func ParseRawValues

func ParseRawValues(rawValues [][]byte) ([]interface{}, error)

ParseRawValues process the raw rows/records from SQL-query

func QueryFields added in v0.5.0

func QueryFields(modelRef interface{}) (string, error)

QueryFields function computes the underscore field-names from the specified model

func RandomNumbers

func RandomNumbers(n int) string

RandomNumbers generates random numbers using rand.Perm and returns []int as string

func RandomString

func RandomString(n int) string

RandomString generates random string of characters and numbers

func StructToFieldValues

func StructToFieldValues(rec interface{}) ([]string, []interface{}, error)

StructToFieldValues converts struct to record fields(underscore) and associated values (columns and values)

func StructToMap

func StructToMap(rec interface{}) (map[string]interface{}, error)

StructToMap function converts struct to map

func StructToMapToCamelCase

func StructToMapToCamelCase(rec interface{}, sep string) (map[string]interface{}, error)

func StructToMapUnderscore

func StructToMapUnderscore(rec interface{}) (map[string]interface{}, error)

StructToMapUnderscore converts struct to map (underscore_fields), for crud-db-table-record

func StructToTagMap

func StructToTagMap(rec interface{}, tag string) (map[string]interface{}, error)

StructToTagMap function converts struct to map (tag/underscore_field), for crud-db-table-record

func TagField

func TagField(rec interface{}, fieldName string, tag string) (string, error)

TagField return the field-tag (e.g. table-column-name) for mcorm tag

func ToCamelCase

func ToCamelCase(text string, sep string) string

func TypeOf

func TypeOf(rec interface{}) reflect.Type

func ValidateSubActionParams

func ValidateSubActionParams(actParams ActionParamsType, subAppIds []string) bool

ValidateSubActionParams validates that subscriber-appIds includes actionParam-appId, for save - create/update tasks

Types

type AccessInfoType

type AccessInfoType struct {
	UserId    string   `json:"userId"`
	Username  string   `json:"username"`
	Email     string   `json:"email"`
	Firstname string   `json:"firstname"`
	Lastname  string   `json:"lastname"`
	RoleId    string   `json:"roleId"`
	RoleIds   []string `json:"roleIds"`
	RoleName  string   `json:"roleName"`
	RoleNames []string `json:"roleNames"`
	IsAdmin   bool     `json:"isAdmin"`
	IsActive  bool     `json:"isActive"`
}

AccessInfoType for CheckUserAccess method value (interface{}) response, and to assert returned value

type AccessLogger

type AccessLogger interface {
	LoginLog(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)
	LogoutLog(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)
}

type AccessLoggerx

type AccessLoggerx interface {
	LoginLog(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)
	LogoutLog(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)
}

type AccessResValueType

type AccessResValueType struct {
	AccessInfo  AccessInfoType `json:"accessInfo"`
	IsAdmin     bool           `json:"isAdmin"`
	SystemAdmin bool           `json:"systemAdmin"`
	UserAdmin   bool           `json:"userAdmin"`
	AppIds      []string       `json:"appIds"`
}

func ComputeAccessResValue

func ComputeAccessResValue(params mcresponse.ResponseMessage) AccessResValueType

ComputeAccessResValue returns the transform access-response-value of AccessResValueType

type ActionParamType

type ActionParamType map[string]interface{}

func DataToValueParam

func DataToValueParam(rec interface{}) (ActionParamType, error)

DataToValueParam accepts only a struct type/model and returns the ActionParamType data camel/Pascal-case keys are converted to underscore-keys to match table-field/columns specs

func ExcludeEmptyIdFields

func ExcludeEmptyIdFields(recs []ActionParamType) []ActionParamType

func ExcludeEmptyIdFromMapRecord

func ExcludeEmptyIdFromMapRecord(rec ActionParamType) ActionParamType

func ExcludeFieldFromMapRecord

func ExcludeFieldFromMapRecord(rec ActionParamType, field string) ActionParamType

ExcludeFieldFromMapRecord exclude id and accessKey fields

type ActionParamsType

type ActionParamsType []ActionParamType

type AppBaseModelPtrType

type AppBaseModelPtrType struct {
	Id          string     `json:"id" db:"id"`
	Language    *string    `json:"language" db:"language"`
	Description *string    `json:"description" db:"description"`
	AppId       *string    `json:"appId" db:"app_id"`       // application-id in a multi-hosted apps environment (e.g. cloud-env)
	IsActive    bool       `json:"isActive" db:"is_active"` // => activate by modelOptionsType settings...
	CreatedBy   *string    `json:"createdBy" db:"created_by"`
	CreatedAt   *time.Time `json:"createdAt" db:"created_at"`
	UpdatedBy   *string    `json:"updatedBy" db:"updated_by"`
	UpdatedAt   *time.Time `json:"updatedAt" db:"updated_at"`
}

type AppBaseModelType

type AppBaseModelType struct {
	Id          string    `json:"id" db:"id"`
	Language    string    `json:"language" db:"language"`
	Description string    `json:"description" db:"description"`
	AppId       string    `json:"appId" db:"app_id"`       // application-id in a multi-hosted apps environment (e.g. cloud-env)
	IsActive    bool      `json:"isActive" db:"is_active"` // => activate by modelOptionsType settings...
	CreatedBy   string    `json:"createdBy" db:"created_by"`
	CreatedAt   time.Time `json:"createdAt" db:"created_at"`
	UpdatedBy   string    `json:"updatedBy" db:"updated_by"`
	UpdatedAt   time.Time `json:"updatedAt" db:"updated_at"`
}

type AppParamsType

type AppParamsType struct {
	AppId      string `json:"appId"`
	AccessKey  string `json:"accessKey"`
	AppName    string `json:"appName"` // optional app-name
	Category   string `json:"category"`
	ServiceId  string `json:"serviceId"`
	ServiceTag string `json:"serviceTag"`
}

AppParamsType is the type for validating app-access

type Application

type Application struct {
	Id          string    `json:"id" db:"id"`
	AppName     string    `json:"appName" db:"app_name"`
	AccessKey   string    `json:"accessKey" db:"access_key"`
	Language    string    `json:"language" db:"language"`
	Description string    `json:"description" db:"description"`
	IsActive    bool      `json:"isActive" db:"is_active"`
	CreatedBy   string    `json:"createdBy" db:"created_by"`
	UpdatedBy   string    `json:"updatedBy" db:"updated_by"`
	CreatedAt   time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt   time.Time `json:"updatedAt" db:"updated_at"`
	AppCategory *string   `json:"appCategory" db:"app_category"`
}

type ApplicationPtr

type ApplicationPtr struct {
	Id          string    `json:"id" db:"id"`
	AppName     string    `json:"appName" db:"app_name"`
	AccessKey   string    `json:"accessKey" db:"access_key"`
	Language    string    `json:"language" db:"language"`
	Description string    `json:"description" db:"description"`
	IsActive    bool      `json:"isActive" db:"is_active"`
	CreatedBy   *string   `json:"createdBy" db:"created_by"`
	UpdatedBy   *string   `json:"updatedBy" db:"updated_by"`
	CreatedAt   time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt   time.Time `json:"updatedAt" db:"updated_at"`
	AppCategory *string   `json:"appCategory" db:"app_category"`
}

type Audit

type Audit struct {
	Id            string      `json:"id" db:"id"`
	TableName     string      `json:"tableName" db:"table_name"`
	LogRecords    interface{} `json:"logRecords" db:"log_records"`
	NewLogRecords interface{} `json:"newLogRecords" db:"new_log_records"`
	LogType       string      `json:"logType" db:"log_type"`
	LogBy         string      `json:"logBy" db:"log_by"`
	LogAt         time.Time   `json:"logAt" db:"log_at"`
}

type AuditLogOptionsType

type AuditLogOptionsType struct {
	AuditTable    string
	TableName     string
	LogRecords    interface{}
	NewLogRecords interface{}
	QueryParams   QueryParamType
	RecordIds     []string
}

type AuditLogOptionsXType

type AuditLogOptionsXType struct {
	AuditTable    string
	TableName     string
	LogRecords    interface{}
	NewLogRecords interface{}
	QueryParams   interface{}
}

type AuditLogger

type AuditLogger interface {
	AuditLog(logType, userId string, options AuditLogOptionsType) (mcresponse.ResponseMessage, error)
}

type AuditLoggerx

type AuditLoggerx interface {
	AuditLog(logType, userId string, options AuditLogOptionsType) (mcresponse.ResponseMessage, error)
}

type AuditParamsType added in v0.6.0

type AuditParamsType struct {
	TableName     string
	LogRecords    interface{}
	NewLogRecords interface{}
	LogType       string
	LogBy         string
	LogAt         time.Time
}

type AuditPtr

type AuditPtr struct {
	Id            string      `json:"id" db:"id"`
	TableName     string      `json:"tableName" db:"table_name"`
	LogRecords    interface{} `json:"logRecords" db:"log_records"`
	NewLogRecords interface{} `json:"newLogRecords" db:"new_log_records"`
	LogType       string      `json:"logType" db:"log_type"`
	LogBy         *string     `json:"logBy" db:"log_by"`
	LogAt         time.Time   `json:"logAt" db:"log_at"`
}

type AuditStampType

type AuditStampType struct {
	IsActive  bool      `json:"isActive"` // => activate by modelOptionsType settings...
	CreatedBy string    `json:"createdBy"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedBy string    `json:"updatedBy"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type AuthError

type AuthError ErrorType

type BaseModelPtrType

type BaseModelPtrType struct {
	Id          string     `json:"id" db:"id"`
	Language    *string    `json:"language" db:"language"`
	Description *string    `json:"description" db:"description"`
	IsActive    bool       `json:"isActive" db:"is_active"` // => activate by modelOptionsType settings...
	CreatedBy   *string    `json:"createdBy" db:"created_by"`
	CreatedAt   *time.Time `json:"createdAt" db:"created_at"`
	UpdatedBy   *string    `json:"updatedBy" db:"updated_by"`
	UpdatedAt   *time.Time `json:"updatedAt" db:"updated_at"`
}

type BaseModelType

type BaseModelType struct {
	Id          string    `json:"id" db:"id"`
	Language    string    `json:"language" db:"language"`
	Description string    `json:"description" db:"description"`
	IsActive    bool      `json:"isActive" db:"is_active"` // => activate by modelOptionsType settings...
	CreatedBy   string    `json:"createdBy" db:"created_by"`
	CreatedAt   time.Time `json:"createdAt" db:"created_at"`
	UpdatedBy   string    `json:"updatedBy" db:"updated_by"`
	UpdatedAt   time.Time `json:"updatedAt" db:"updated_at"`
}

type CheckAccessParamsType

type CheckAccessParamsType struct {
	AccessDb     *sqlx.DB     `json:"accessDb"`
	UserInfo     UserInfoType `json:"userInfo"`
	TableName    string       `json:"tableName"`
	RecordIds    []string     `json:"recordIds"` // for update, delete and read tasks
	AccessTable  string       `json:"accessTable"`
	UserTable    string       `json:"userTable"`
	RoleTable    string       `json:"roleTable"`
	ServiceTable string       `json:"serviceTable"`
	ProfileTable string       `json:"profileTable"`
}

type CheckAccessType

type CheckAccessType struct {
	UserId         string            `json:"userId" mcorm:"userId"`
	RoleId         string            `json:"roleId" mcorm:"roleId"`
	RoleIds        []string          `json:"roleIds" mcorm:"roleIds"`
	IsActive       bool              `json:"isActive" mcorm:"isActive"`
	IsAdmin        bool              `json:"isAdmin" mcorm:"isAdmin"`
	RoleServices   []RoleServiceType `json:"roleServices" mcorm:"roleServices"`
	TableId        string            `json:"tableId" mcorm:"tableId"`
	OwnerPermitted bool              `json:"ownerPermitted"`
}

type ConnectError

type ConnectError ErrorType

type CreateError

type CreateError ErrorType

type CreateLogger

type CreateLogger interface {
	CreateLog(table string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type CreateLoggerx

type CreateLoggerx interface {
	CreateLog(table string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type CreateQueryError

type CreateQueryError ErrorType

type CreateQueryObject

type CreateQueryObject struct {
	CreateQuery string
	FieldNames  []string
	FieldValues [][]interface{}
}

type CreateQueryResult

type CreateQueryResult struct {
	CreateQueryObject CreateQueryObject
	Ok                bool
	Message           string
}

func ComputeCreateQuery

func ComputeCreateQuery(tableName string, actionParams ActionParamsType) CreateQueryResult

ComputeCreateQuery function computes insert SQL scripts. It returns createScripts []string and err error

type Crud

type Crud struct {
	CrudParamsType
	CrudOptionsType
	CreateItems    ActionParamsType
	UpdateItems    ActionParamsType
	CurrentRecords []map[string]interface{}
	TransLog       LogParamX
	CacheKey       string // Unique for exactly the same query
}

Crud object / struct

func NewCrud

func NewCrud(params CrudParamsType, options CrudOptionsType) (crudInstance *Crud)

NewCrud constructor returns a new crud-instance

func (*Crud) CheckLoginStatus

func (crud *Crud) CheckLoginStatus() mcresponse.ResponseMessage

CheckLoginStatus method checks if the user exists and has active login status/token

func (*Crud) CheckSaveTaskType

func (crud *Crud) CheckSaveTaskType() string

CheckSaveTaskType determines the crud-task type based on actionParams[0] record (i.e. first record in the array)

func (*Crud) CheckTaskAccess

func (crud *Crud) CheckTaskAccess() mcresponse.ResponseMessage

CheckTaskAccess method determines the access by role-assignment

func (*Crud) CheckUserAccess

func (crud *Crud) CheckUserAccess() mcresponse.ResponseMessage

CheckUserAccess method determines the user access status: active, valid login and admin

func (*Crud) Create

func (crud *Crud) Create(recs ActionParamsType) mcresponse.ResponseMessage

Create method creates new record(s)

func (*Crud) CustomSelectQuery added in v0.5.0

func (crud *Crud) CustomSelectQuery(params CustomSelectQueryParamsType) mcresponse.ResponseMessage

CustomSelectQuery method obtain the query result for the specified selectQuery, tableName and modelPointer and optional fieldPositionalValues.

func (*Crud) DeleteAll

func (crud *Crud) DeleteAll() mcresponse.ResponseMessage

DeleteAll method deletes or removes all records in the tables. Recommended for admin-users only Use if and only if you know what you are doing

func (*Crud) DeleteById

func (crud *Crud) DeleteById(id string) mcresponse.ResponseMessage

DeleteById method deletes or removes record(s) by record-id(s)

func (*Crud) DeleteByIds

func (crud *Crud) DeleteByIds() mcresponse.ResponseMessage

DeleteByIds method deletes or removes record(s) by record-id(s)

func (*Crud) DeleteByParam

func (crud *Crud) DeleteByParam() mcresponse.ResponseMessage

DeleteByParam method deletes or removes record(s) by query-parameters or where conditions

func (*Crud) DeleteRecord

func (crud *Crud) DeleteRecord() mcresponse.ResponseMessage

DeleteRecord method deletes/removes record(s) by recordIds or queryParams

func (*Crud) GetAll

func (crud *Crud) GetAll() mcresponse.ResponseMessage

GetAll method fetches/gets/reads all record(s), constrained by optional skip and limit parameters

func (*Crud) GetAll1

func (crud *Crud) GetAll1() mcresponse.ResponseMessage

GetAll1 method fetches/gets/reads all record(s), constrained by optional skip and limit parameters

func (*Crud) GetById

func (crud *Crud) GetById(id string) mcresponse.ResponseMessage

func (*Crud) GetById1

func (crud *Crud) GetById1(id string) mcresponse.ResponseMessage

func (*Crud) GetByIds

func (crud *Crud) GetByIds() mcresponse.ResponseMessage

GetByIds method fetches/gets/reads records that met the specified record-ids, constrained by optional skip and limit parameters

func (*Crud) GetByIds1

func (crud *Crud) GetByIds1() mcresponse.ResponseMessage

func (*Crud) GetByParam

func (crud *Crud) GetByParam() mcresponse.ResponseMessage

GetByParam method fetches/gets/reads records that met the specified query-params or where conditions, constrained by optional skip and limit parameters

func (*Crud) GetByParam1

func (crud *Crud) GetByParam1() mcresponse.ResponseMessage

GetByParam1 method fetches/gets/reads records that met the specified query-params or where conditions, constrained by optional skip and limit parameters

func (*Crud) GetRecord

func (crud *Crud) GetRecord() mcresponse.ResponseMessage

GetRecord method fetches records by recordIds, queryParams or all

func (*Crud) GetRecords

func (crud *Crud) GetRecords() mcresponse.ResponseMessage

GetRecords method fetches records by recordIds, queryParams or all - lookup-items (no-access-constraint)

func (*Crud) GetRoleServices

func (crud *Crud) GetRoleServices(accessDb *sqlx.DB, roleTable string, userRoleId string, serviceIds []string) ([]RoleServiceType, error)

GetRoleServices method process and returns the permission to user / user-group/roleId for the specified service items

func (*Crud) GetStream

func (crud *Crud) GetStream() mcresponse.ResponseMessage

func (*Crud) RecordsCount

func (crud *Crud) RecordsCount() (totalRecords int, ownerRecords int, err error)

RecordsCount returns the totalRecordsCount, ownerRecordsCount and error, if applicable

func (*Crud) SaveRecord

func (crud *Crud) SaveRecord() mcresponse.ResponseMessage

SaveRecord method creates new record(s) or updates existing record(s)

func (*Crud) String

func (crud *Crud) String() string

String() method implementation for crud instance/object

func (*Crud) TaskPermissionById

func (crud *Crud) TaskPermissionById(taskType string) mcresponse.ResponseMessage

TaskPermissionById method determines the access permission by owner, role/group (on coll/table or doc/record(s)) or admin for various : create/insert, update, delete/remove, read

func (*Crud) TaskPermissionByParam

func (crud *Crud) TaskPermissionByParam(taskType string) mcresponse.ResponseMessage

func (*Crud) Update

func (crud *Crud) Update(recs ActionParamsType) mcresponse.ResponseMessage

Update method updates existing record(s)

func (*Crud) UpdateById

func (crud *Crud) UpdateById(rec ActionParamType, id string) mcresponse.ResponseMessage

UpdateById method updates existing records (in batch) that met the specified record-id(s)

func (*Crud) UpdateByIds

func (crud *Crud) UpdateByIds(rec ActionParamType) mcresponse.ResponseMessage

UpdateByIds method updates existing records (in batch) that met the specified record-id(s)

func (*Crud) UpdateByParam

func (crud *Crud) UpdateByParam(rec ActionParamType) mcresponse.ResponseMessage

UpdateByParam method updates existing records (in batch) that met the specified query-params or where conditions

type CrudOptionsType

type CrudOptionsType struct {
	CheckAccess           bool
	CacheResult           bool
	BulkCreate            bool
	AccessDb              *sqlx.DB
	AuditDb               *sqlx.DB
	ServiceDb             *sqlx.DB
	AuditTable            string
	ServiceTable          string
	UserTable             string
	RoleTable             string
	AccessTable           string
	VerifyTable           string
	ProfileTable          string
	UserRoleTable         string
	MaxQueryLimit         int
	LogCrud               bool
	LogCreate             bool
	LogUpdate             bool
	LogRead               bool
	LogDelete             bool
	LogLogin              bool
	LogLogout             bool
	UnAuthorizedMessage   string
	RecExistMessage       string
	CacheExpire           int
	LoginTimeout          int
	UsernameExistsMessage string
	EmailExistsMessage    string
	MsgFrom               string
	ModelOptions          ModelOptionsType
	FieldSeparator        string
	AppDbs                []string
	AppTables             []string
	QueryFieldType        string
}

type CrudParamsType

type CrudParamsType struct {
	ModelRef      interface{}      `json:"-"`
	ModelPointer  interface{}      `json:"-"`
	AppDb         *sqlx.DB         `json:"-"`
	TableName     string           `json:"-"`
	UserInfo      UserInfoType     `json:"userInfo"`
	ActionParams  ActionParamsType `json:"actionParams"`
	QueryParams   QueryParamType   `json:"queryParams"`
	RecordIds     []string         `json:"recordIds"`
	ProjectParams ProjectParamType `json:"projectParams"`
	SortParams    SortParamType    `json:"sortParams"`
	Token         string           `json:"token"`
	Skip          int              `json:"skip"`
	Limit         int              `json:"limit"`
	TaskName      string           `json:"taskName"`
	TaskType      string           `json:"taskType"`
	AppParams     AppParamsType    `json:"appParams"`
}

CrudParamsType is the struct type for receiving, composing and passing CRUD inputs

func TransformGetCrudParams

func TransformGetCrudParams(params CrudParamsType, accessRes mcresponse.ResponseMessage) CrudParamsType

TransformGetCrudParams compose the crud-params for read-query

type CrudResultType

type CrudResultType struct {
	QueryParam   QueryParamType             `json:"queryParam"`
	RecordIds    []string                   `json:"recordIds"`
	RecordsCount int                        `json:"recordsCount"`
	Records      []map[string]interface{}   `json:"records"`
	TaskType     string                     `json:"taskType"`
	LogRes       mcresponse.ResponseMessage `json:"logRes"`
}

type CrudTasksType

type CrudTasksType struct {
	Create string
	Insert string
	Update string
	Read   string
	Delete string
	Remove string
	Login  string
	Logout string
	Other  string
}

func CrudTasks

func CrudTasks() CrudTasksType

type CustomSelectQueryParamsType added in v0.5.0

type CustomSelectQueryParamsType struct {
	SelectQuery                string        `json:"selectQuery"`
	CountQuery                 string        `json:"countQuery"`
	TableName                  string        `json:"tableName"`
	ModelPointer               interface{}   `json:"modelPointer"`
	QueryPositionalFieldValues []interface{} `json:"queryPositionalFieldValues"`
}

type DbConfig

type DbConfig struct {
	DbType        string           `json:"dbType"`
	Host          string           `json:"host"`
	Username      string           `json:"username"`
	Password      string           `json:"password"`
	DbName        string           `json:"dbName"`
	Filename      string           `json:"filename"`
	Location      string           `json:"location"`
	Port          uint32           `json:"port"`
	PoolSize      uint             `json:"poolSize"`
	Url           string           `json:"url"`
	Timezone      string           `json:"timezone"`
	SecureOptions DbSecureType     `json:"secureOptions"`
	Options       DbConnectOptions `json:"options"`
	PermitDBUrl   bool             `json:"permitDBUrl"`
}

func (DbConfig) CloseDb

func (dbConfig DbConfig) CloseDb()

func (DbConfig) CloseDbx

func (dbConfig DbConfig) CloseDbx()

func (DbConfig) OpenDb

func (dbConfig DbConfig) OpenDb() (*sql.DB, error)

func (DbConfig) OpenDbx

func (dbConfig DbConfig) OpenDbx() (*sqlx.DB, error)

type DbConfigType

type DbConfigType struct {
	Host         string       `json:"host"`
	Username     string       `json:"username"`
	Password     string       `json:"password"`
	DbName       string       `json:"dbName"`
	Filename     string       `json:"filename"`
	Location     string       `json:"location"`
	Port         uint32       `json:"port"`
	DbType       string       `json:"dbType"`
	PoolSize     uint         `json:"poolSize"`
	Url          string       `json:"url"`
	SecureOption DbSecureType `json:"secureOption"`
}

type DbConnectOptions

type DbConnectOptions map[string]interface{}

type DbConnectionType

type DbConnectionType *sqlx.DB

type DbSecureType

type DbSecureType struct {
	SecureAccess bool   `json:"secureAccess"`
	SecureCert   string `json:"secureCert"`
	SecureKey    string `json:"secureKey"`
	SslMode      string `json:"sslMode"`
}

type DeleteCrudParamsType

type DeleteCrudParamsType struct {
	CrudParams         CrudParamsType
	CrudOptions        CrudOptionsType
	GetTableFields     []string
	TableFieldPointers []interface{}
	AuditLog           bool
}

type DeleteError

type DeleteError ErrorType

type DeleteLogger

type DeleteLogger interface {
	DeleteLog(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type DeleteLoggerx

type DeleteLoggerx interface {
	DeleteLog(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type DeleteParamsType

type DeleteParamsType struct {
	UserInfo    UserInfoType   `json:"userInfo"`
	RecordIds   []string       `json:"recordIds"`
	QueryParams QueryParamType `json:"queryParams"`
}

type DeleteQueryError

type DeleteQueryError ErrorType

type DeleteQueryObject

type DeleteQueryObject struct {
	DeleteQuery string
	FieldValues []interface{}
	WhereQuery  WhereQueryObject
}

type DeleteQueryResult

type DeleteQueryResult struct {
	DeleteQueryObject DeleteQueryObject
	Ok                bool
	Message           string
}

func ComputeDeleteQueryById

func ComputeDeleteQueryById(tableName string, recordId string) DeleteQueryResult

ComputeDeleteQueryById function computes delete SQL scripts by id(s)

func ComputeDeleteQueryByIds

func ComputeDeleteQueryByIds(tableName string, recordIds []string) DeleteQueryResult

ComputeDeleteQueryByIds function computes delete SQL scripts by id(s)

func ComputeDeleteQueryByParam

func ComputeDeleteQueryByParam(tableName string, queryParam QueryParamType) DeleteQueryResult

ComputeDeleteQueryByParam function computes delete SQL scripts by parameter specifications

type EmailAddressType

type EmailAddressType = map[string]string

type EmailUserNameType

type EmailUserNameType struct {
	Email    string
	Username string
}

func EmailUsername

func EmailUsername(loginName string) EmailUserNameType

EmailUsername processes and returns the loginName as email or username

type ErrorType

type ErrorType struct {
	Code    string
	Message string
}

ErrorType provides the structure for error reporting

func (ErrorType) Error

func (err ErrorType) Error() string

sample Error() implementation

type FieldValueType

type FieldValueType interface{}

type GetCrudParamsType

type GetCrudParamsType struct {
	CrudParams         CrudParamsType
	CrudOptions        CrudOptionsType
	GetTableFields     []string
	TableFieldPointers []interface{}
	AuditLog           bool
}

type GetParamsType

type GetParamsType struct {
	UserInfo     UserInfoType     `json:"userInfo"`
	Skip         int              `json:"skip"`
	Limit        int              `json:"limit"`
	RecordIds    []string         `json:"recordIds"`
	QueryParams  QueryParamType   `json:"queryParams"`
	SortParam    SortParamType    `json:"sortParams"`
	ProjectParam ProjectParamType `json:"projectParam"`
}

type GetResultType

type GetResultType struct {
	Records  []map[string]interface{}   `json:"records"`
	Stats    GetStatType                `json:"stats"`
	LogRes   mcresponse.ResponseMessage `json:"logRes"`
	TaskType string                     `json:"taskType"`
}

type GetStatType

type GetStatType struct {
	Skip              int            `json:"skip"`
	Limit             int            `json:"limit"`
	RecordsCount      int            `json:"recordsCount"`
	TotalRecordsCount int            `json:"totalRecordsCount"`
	QueryParam        QueryParamType `json:"queryParam"`
	RecordIds         []string       `json:"recordIds"`
	Expire            int            `json:"expire"`
}

type IDs

type IDs []string

type LogParam

type LogParam struct {
	AuditDb    *sql.DB
	AuditTable string
}

LogParam interfaces / types

func NewAuditLog

func NewAuditLog(auditDb *sql.DB, auditTable string) LogParam

func (LogParam) AuditLog

func (log LogParam) AuditLog(logType, userId string, options AuditLogOptionsType) (mcresponse.ResponseMessage, error)

func (LogParam) CreateLog

func (log LogParam) CreateLog(table string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

func (LogParam) CustomLog added in v0.6.0

func (log LogParam) CustomLog(params AuditParamsType) (mcresponse.ResponseMessage, error)

func (LogParam) DeleteLog

func (log LogParam) DeleteLog(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

func (LogParam) LoginLog

func (log LogParam) LoginLog(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)

func (LogParam) LogoutLog

func (log LogParam) LogoutLog(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)

func (LogParam) ReadLog

func (log LogParam) ReadLog(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

func (LogParam) String

func (log LogParam) String() string

String() function implementation

func (LogParam) UpdateLog

func (log LogParam) UpdateLog(tableName string, logRecords interface{}, newLogRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

type LogParamX

type LogParamX struct {
	AuditDb    *sqlx.DB
	AuditTable string
}

LogParamX interfaces / types

func NewAuditLogx

func NewAuditLogx(auditDb *sqlx.DB, auditTable string) LogParamX

func (LogParamX) AuditLog

func (log LogParamX) AuditLog(logType, userId string, options AuditLogOptionsType) (mcresponse.ResponseMessage, error)

func (LogParamX) CreateLogx

func (log LogParamX) CreateLogx(table string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

func (LogParamX) CustomLog added in v0.6.0

func (log LogParamX) CustomLog(params AuditParamsType) (mcresponse.ResponseMessage, error)

func (LogParamX) DeleteLogx

func (log LogParamX) DeleteLogx(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

func (LogParamX) LoginLogx

func (log LogParamX) LoginLogx(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)

func (LogParamX) LogoutLogx

func (log LogParamX) LogoutLogx(logRecords interface{}, userId string, tableName string) (mcresponse.ResponseMessage, error)

func (LogParamX) ReadLogx

func (log LogParamX) ReadLogx(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

func (LogParamX) String

func (log LogParamX) String() string

String() function implementation

func (LogParamX) UpdateLogx

func (log LogParamX) UpdateLogx(tableName string, logRecords interface{}, newLogRecords interface{}, userId string) (mcresponse.ResponseMessage, error)

type LogRecordsType

type LogRecordsType struct {
	LogRecords   interface{}    `json:"logRecords"`
	QueryParam   QueryParamType `json:"queryParam"`
	RecordIds    []string       `json:"recordIds"`
	TableFields  []string       `json:"tableFields"`
	TableRecords []interface{}  `json:"tableRecords"`
}

type MessageObject

type MessageObject map[string]string

type ModelOptionsType

type ModelOptionsType struct {
	TimeStamp   bool
	ActiveStamp bool
	ActorStamp  bool
}

type MultiUpdateQueryResult

type MultiUpdateQueryResult struct {
	UpdateQueryObjects []UpdateQueryObject
	Ok                 bool
	Message            string
}

func ComputeUpdateQuery

func ComputeUpdateQuery(tableName string, actionParams ActionParamsType) MultiUpdateQueryResult

ComputeUpdateQuery function computes update SQL script. It returns updateScript, updateValues []interface{} and/or err error

type OkResponse

type OkResponse struct {
	Ok bool `json:"ok"`
}

type Profile

type Profile struct {
	BaseModelType
	UserId        string      `json:"userId"`
	Firstname     string      `json:"firstname"`
	Lastname      string      `json:"lastname"`
	Middlename    string      `json:"middlename"`
	Phone         string      `json:"phone"`
	Emails        interface{} `json:"emails"` // slice of EmailAddressType OR EmailAddresses type
	RecEmail      string      `json:"recEmail"`
	RoleId        string      `json:"roleId"`
	DateOfBirth   time.Time   `json:"dateOfBirth"`
	TwoFactorAuth bool        `json:"twoFactorAuth"`
	AuthAgent     string      `json:"authAgent"`
	AuthPhone     string      `json:"authPhone"`
	PostalCode    string      `json:"postalCode"`
}

type ProjectParamType

type ProjectParamType map[string]int // 1 or true for inclusion, 0 or false for exclusion

type QueryParamType

type QueryParamType map[string]interface{}

type ReadError

type ReadError ErrorType

type ReadLogger

type ReadLogger interface {
	ReadLog(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type ReadLoggerx

type ReadLoggerx interface {
	ReadLog(tableName string, logRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type RelationBaseModelPtrType

type RelationBaseModelPtrType struct {
	Description *string    `json:"description" db:"description"`
	IsActive    bool       `json:"isActive" db:"is_active"` // => activate by modelOptionsType settings...
	CreatedBy   *string    `json:"createdBy" db:"created_by"`
	CreatedAt   *time.Time `json:"createdAt" db:"created_at"`
	UpdatedBy   *string    `json:"updatedBy" db:"updated_by"`
	UpdatedAt   *time.Time `json:"updatedAt" db:"updated_at"`
}

type RelationBaseModelType

type RelationBaseModelType struct {
	Description string    `json:"description" db:"description"`
	IsActive    bool      `json:"isActive" db:"is_active"` // => activate by modelOptionsType settings...
	CreatedBy   string    `json:"createdBy" db:"created_by"`
	CreatedAt   time.Time `json:"createdAt" db:"created_at"`
	UpdatedBy   string    `json:"updatedBy" db:"updated_by"`
	UpdatedAt   time.Time `json:"updatedAt" db:"updated_at"`
}

type RoleFuncType

type RoleFuncType func(it1 string, it2 RoleServiceType) bool

type RoleServiceType

type RoleServiceType struct {
	ServiceId            string   `json:"serviceId"`
	RoleId               string   `json:"roleId"`
	RoleIds              []string `json:"roleIds"`
	ServiceCategory      string   `json:"serviceCategory"`
	CanRead              bool     `json:"canRead"`
	CanCreate            bool     `json:"canCreate"`
	CanUpdate            bool     `json:"canUpdate"`
	CanDelete            bool     `json:"canDelete"`
	CanCrud              bool     `json:"canCrud"`
	TableAccessPermitted bool     `json:"tableAccessPermitted"`
}

type SaveCrudParamsType

type SaveCrudParamsType struct {
	CrudParams         CrudParamsType
	CrudOptions        CrudOptionsType
	CreateTableFields  []string
	UpdateTableFields  []string
	GetTableFields     []string
	TableFieldPointers []interface{}
	AuditLog           bool
}

type SaveError

type SaveError ErrorType

type SaveParamsType

type SaveParamsType struct {
	UserInfo    UserInfoType   `json:"userInfo"`
	QueryParams QueryParamType `json:"queryParams"`
	RecordIds   []string       `json:"recordIds"`
}

type SaveResultType

type SaveResultType struct {
	QueryParam   QueryParamType             `json:"queryParam"`
	RecordIds    []string                   `json:"recordIds"`
	RecordsCount int                        `json:"recordsCount"`
	TaskType     string                     `json:"taskType"`
	LogRes       mcresponse.ResponseMessage `json:"logRes"`
}

type SelectQueryError

type SelectQueryError ErrorType

type SelectQueryObject

type SelectQueryObject struct {
	SelectQuery string
	FieldValues []interface{}
	WhereQuery  WhereQueryObject
}

type SelectQueryOptions

type SelectQueryOptions struct {
	Skip  int
	Limit int
}

type SelectQueryResult

type SelectQueryResult struct {
	SelectQueryObject SelectQueryObject
	Ok                bool
	Message           string
}

func ComputeSelectQueryAll

func ComputeSelectQueryAll(modelRef interface{}, tableName string, options SelectQueryOptions) SelectQueryResult

ComputeSelectQueryAll compose select SQL script to retrieve all table-records. The query may be constraint by skip(offset) and limit options

func ComputeSelectQueryById

func ComputeSelectQueryById(modelRef interface{}, tableName string, recordId string, options SelectQueryOptions) SelectQueryResult

ComputeSelectQueryById compose select SQL scripts by id

func ComputeSelectQueryByIds

func ComputeSelectQueryByIds(modelRef interface{}, tableName string, recordIds []string, options SelectQueryOptions) SelectQueryResult

ComputeSelectQueryByIds compose select SQL scripts by ids

func ComputeSelectQueryByParam

func ComputeSelectQueryByParam(modelRef interface{}, tableName string, queryParam QueryParamType, options SelectQueryOptions) SelectQueryResult

ComputeSelectQueryByParam compose SELECT query from the where-parameters

type SortParamType

type SortParamType map[string]int // 1 for "asc", -1 for "desc"

type TaskPermissionType

type TaskPermissionType struct {
	Ok             bool     `json:"ok"`
	IsAdmin        bool     `json:"isAdmin"`
	IsActive       bool     `json:"isActive"`
	UserId         string   `json:"userId"`
	RoleId         string   `json:"roleId"`
	RoleIds        []string `json:"roleIds"`
	RoleName       string   `json:"roleName"`
	RoleNames      []string `json:"roleNames"`
	OwnerPermitted bool     `json:"ownerPermitted"`
}

TaskPermissionType for TaskPermission method value (interface{}) response, and to assert returned value

type UpdateError

type UpdateError ErrorType

type UpdateLogger

type UpdateLogger interface {
	UpdateLog(tableName string, logRecords interface{}, newLogRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type UpdateLoggerx

type UpdateLoggerx interface {
	UpdateLog(tableName string, logRecords interface{}, newLogRecords interface{}, userId string) (mcresponse.ResponseMessage, error)
}

type UpdateQueryError

type UpdateQueryError ErrorType

type UpdateQueryObject

type UpdateQueryObject struct {
	UpdateQuery string
	FieldNames  []string
	FieldValues []interface{}
	WhereQuery  WhereQueryObject
}

type UpdateQueryResult

type UpdateQueryResult struct {
	UpdateQueryObject UpdateQueryObject
	Ok                bool
	Message           string
}

func ComputeUpdateQueryById

func ComputeUpdateQueryById(tableName string, actionParam ActionParamType, recordId string) UpdateQueryResult

ComputeUpdateQueryById function computes update SQL scripts by recordId. It returns updateScript, updateValues []interface{} and/or err error

func ComputeUpdateQueryByIds

func ComputeUpdateQueryByIds(tableName string, actionParam ActionParamType, recordIds []string) UpdateQueryResult

ComputeUpdateQueryByIds function computes update SQL scripts by recordIds. It returns updateScript, updateValues []interface{} and/or err error

func ComputeUpdateQueryByParam

func ComputeUpdateQueryByParam(tableName string, actionParam ActionParamType, queryParam QueryParamType) UpdateQueryResult

ComputeUpdateQueryByParam function computes update SQL scripts by queryParams. It returns updateScript, updateValues []interface{} and/or err error

type UserInfoType

type UserInfoType struct {
	UserId    string `json:"userId" form:"userId" mcorm:"user_id"`
	Firstname string `json:"firstname" mcorm:"firstname"`
	Lastname  string `json:"lastname" mcorm:"lastname"`
	Language  string `json:"language" mcorm:"language"`
	LoginName string `json:"loginName" form:"loginName" mcorm:"login_name"`
	Token     string `json:"token" mcorm:"token"`
	Expire    int64  `json:"expire" mcorm:"expire"`
	Email     string `json:"email" form:"email" mcorm:"email"`
	RoleId    string `json:"roleId" mcorm:"role_id"`
}

type ValidateResponseType

type ValidateResponseType struct {
	Ok     bool          `json:"ok"`
	Errors MessageObject `json:"errors"`
}

type ValueToDataType

type ValueToDataType map[string]interface{}

type WhereQueryError

type WhereQueryError ErrorType

type WhereQueryObject

type WhereQueryObject struct {
	WhereQuery  string
	FieldValues []interface{}
}

type WhereQueryResult

type WhereQueryResult struct {
	WhereQueryObject WhereQueryObject
	Ok               bool
	Message          string
}

func ComputeWhereQuery

func ComputeWhereQuery(queryParams QueryParamType, fieldLength int) WhereQueryResult

ComputeWhereQuery function computes the multi-cases where-conditions for crud-operations

Jump to

Keyboard shortcuts

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