Documentation ¶
Index ¶
- Constants
- Variables
- func NewArgumentTypeNotMatchedError(fieldName string, requiredType code.Type, givenType code.Type) error
- func NewIncompatibleComparatorError(comparator Comparator, field code.StructField) error
- func NewIncompatibleUpdateOperatorError(updateOperator UpdateOperator, fieldReference FieldReference) error
- func NewInvalidQueryError(queryTokens []string) error
- func NewInvalidSortError(sortTokens []string) error
- func NewOperationReturnCountUnmatchedError(returnCount int) error
- func NewStructFieldNotFoundError(tokens []string) error
- func NewUnknownOperationError(operationName string) error
- func NewUnsupportedReturnError(givenType code.Type, index int) error
- type Comparator
- type CountOperation
- type DeleteOperation
- type FieldReference
- type FindOperation
- type InsertOperation
- type MethodSpec
- type Operation
- type Operator
- type Ordering
- type Predicate
- type QueryMode
- type QuerySpec
- type Sort
- type Update
- type UpdateField
- type UpdateFields
- type UpdateModel
- type UpdateOperation
- type UpdateOperator
Constants ¶
const ( OrderingAscending = "ASC" OrderingDescending = "DESC" )
Ordering constants
Variables ¶
var ( ErrQueryRequired = errors.New("spec: query is required") ErrInvalidParam = errors.New("spec: parameters do not match the query") ErrInvalidUpdateFields = errors.New("spec: update fields are invalid") ErrContextParamRequired = errors.New("spec: context parameter is required") ErrLimitAmountRequired = errors.New("spec: limit amount is required") ErrLimitNonPositive = errors.New("spec: limit value must be positive") ErrLimitOnFindOne = errors.New("spec: cannot specify limit on find one") )
parsing error constants
Functions ¶
func NewArgumentTypeNotMatchedError ¶
func NewArgumentTypeNotMatchedError(fieldName string, requiredType code.Type, givenType code.Type) error
NewArgumentTypeNotMatchedError creates argumentTypeNotMatchedError
func NewIncompatibleComparatorError ¶
func NewIncompatibleComparatorError(comparator Comparator, field code.StructField) error
NewIncompatibleComparatorError creates incompatibleComparatorError
func NewIncompatibleUpdateOperatorError ¶
func NewIncompatibleUpdateOperatorError(updateOperator UpdateOperator, fieldReference FieldReference) error
NewIncompatibleUpdateOperatorError creates incompatibleUpdateOperatorError
func NewInvalidQueryError ¶
NewInvalidQueryError creates invalidQueryError
func NewInvalidSortError ¶
NewInvalidSortError creates invalidSortError
func NewOperationReturnCountUnmatchedError ¶
NewOperationReturnCountUnmatchedError creates operationReturnCountUnmatchedError.
func NewStructFieldNotFoundError ¶
NewStructFieldNotFoundError creates structFieldNotFoundError
func NewUnknownOperationError ¶
NewUnknownOperationError creates unknownOperationError
Types ¶
type Comparator ¶
type Comparator string
Comparator is a comparison operator of the condition to query the data
const ( ComparatorNot Comparator = "NOT" ComparatorEqual Comparator = "EQUAL" ComparatorLessThan Comparator = "LESS_THAN" ComparatorLessThanEqual Comparator = "LESS_THAN_EQUAL" ComparatorGreaterThan Comparator = "GREATER_THAN" ComparatorGreaterThanEqual Comparator = "GREATER_THAN_EQUAL" ComparatorBetween Comparator = "BETWEEN" ComparatorIn Comparator = "IN" ComparatorNotIn Comparator = "NOT_IN" ComparatorTrue Comparator = "EQUAL_TRUE" ComparatorFalse Comparator = "EQUAL_FALSE" ComparatorExists Comparator = "EXISTS" ComparatorNotExists Comparator = "NOT_EXISTS" )
comparator types
func (Comparator) ArgumentTypeFromFieldType ¶
func (c Comparator) ArgumentTypeFromFieldType(t code.Type) code.Type
ArgumentTypeFromFieldType returns a type of required argument from the given struct field type.
func (Comparator) NumberOfArguments ¶
func (c Comparator) NumberOfArguments() int
NumberOfArguments returns the number of arguments required to perform the comparison.
type CountOperation ¶
type CountOperation struct {
Query QuerySpec
}
CountOperation is a method specification for count operations
func (CountOperation) Name ¶
func (o CountOperation) Name() string
Name returns "Count" operation name
type DeleteOperation ¶
DeleteOperation is a method specification for delete operations
func (DeleteOperation) Name ¶
func (o DeleteOperation) Name() string
Name returns "Delete" operation name
type FieldReference ¶
type FieldReference []code.StructField
FieldReference is a reference path to access to the field
func (FieldReference) ReferencedField ¶
func (r FieldReference) ReferencedField() code.StructField
ReferencedField returns the last struct field
func (FieldReference) ReferencingCode ¶
func (r FieldReference) ReferencingCode() string
ReferencingCode returns a string containing name of the referenced fields concatenating with period (.).
type FindOperation ¶
FindOperation is a method specification for find operations
type InsertOperation ¶
type InsertOperation struct {
Mode QueryMode
}
InsertOperation is a method specification for insert operations
func (InsertOperation) Name ¶
func (o InsertOperation) Name() string
Name returns "Insert" operation name
type MethodSpec ¶
MethodSpec is a method specification inside repository specification
type Operation ¶
type Operation interface {
Name() string
}
Operation is an interface for any kind of operation
type Predicate ¶
type Predicate struct { FieldReference FieldReference Comparator Comparator ParamIndex int }
Predicate is a criteria for querying a field
type QuerySpec ¶
QuerySpec is a set of conditions of querying the database
func (QuerySpec) NumberOfArguments ¶
NumberOfArguments returns number of arguments required to perform the query
type Sort ¶
type Sort struct { FieldReference FieldReference Ordering Ordering }
Sort is a detail of sorting find result
type UpdateField ¶
type UpdateField struct { FieldReference FieldReference ParamIndex int Operator UpdateOperator }
UpdateField stores mapping between field name in the model and the parameter index.
type UpdateFields ¶
type UpdateFields []UpdateField
UpdateFields is a type of update operation that update specific fields
func (UpdateFields) Name ¶
func (u UpdateFields) Name() string
Name returns UpdateFields name 'Fields'
func (UpdateFields) NumberOfArguments ¶
func (u UpdateFields) NumberOfArguments() int
NumberOfArguments returns number of update fields
type UpdateModel ¶
type UpdateModel struct { }
UpdateModel is a type of update operation that update the whole model
func (UpdateModel) NumberOfArguments ¶
func (u UpdateModel) NumberOfArguments() int
NumberOfArguments returns 1
type UpdateOperation ¶
UpdateOperation is a method specification for update operations
func (UpdateOperation) Name ¶
func (o UpdateOperation) Name() string
Name returns "Update" operation name
type UpdateOperator ¶
type UpdateOperator string
UpdateOperator is a custom type that declares update operator to be used in an update operation
const ( UpdateOperatorSet UpdateOperator = "SET" UpdateOperatorPush UpdateOperator = "PUSH" UpdateOperatorInc UpdateOperator = "INC" )
UpdateOperator constants
func (UpdateOperator) ArgumentType ¶
func (o UpdateOperator) ArgumentType(fieldType code.Type) code.Type
ArgumentType returns type that is required for function parameter
func (UpdateOperator) NumberOfArguments ¶
func (o UpdateOperator) NumberOfArguments() int
NumberOfArguments returns number of arguments required to perform an update operation