Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInternalError is an internal sorting error. ErrInternalError = errors.New("internal error") // ErrInvalidField is an error returned by the parser when the sorting expression // contains invalid field name. ErrInvalidField = errors.New("invalid field") // ErrInvalidSyntax is an error returned by the parser when the sorting expression // has invalid syntax. ErrInvalidSyntax = errors.New("invalid syntax") // ErrSortingForbidden is an error returned by the parser when the sorting // is forbidden of specific field. ErrSortingForbidden = errors.New("sorting forbidden") )
Functions ¶
This section is empty.
Types ¶
type ErrHandlerFn ¶
ErrHandlerFn is a function that handles errors
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses an order by expression
func NewParser ¶
func NewParser(msg protoreflect.MessageDescriptor, opts ...ParserOpt) (*Parser, error)
NewParser creates a new parser with a message descriptor and optional error handler.
func (*Parser) Parse ¶
func (p *Parser) Parse(orderBy string) (oe *expr.OrderByExpr, err error)
Parse parses a sorting order option and returns an expression.
func (*Parser) Reset ¶
func (p *Parser) Reset(msgDesc protoreflect.MessageDescriptor, opts ...ParserOpt) error
Reset resets the parser with a new message descriptor and optional error handler. If the error handler is nil, the parser will handling errors.
type ParserOpt ¶
ParserOpt is an option function for the parser.
func ErrHandler ¶
func ErrHandler(fn scanner.ErrorHandler) ParserOpt
ErrHandler sets the error handler for the parser.
Click to show internal directories.
Click to hide internal directories.