Documentation ¶
Overview ¶
Package query facilitates the translation of a result selector into a PostgresSQL conditional query string, incorporating sorting and paging functionalities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder represents a query builder used to construct PostgresSQL conditional query strings with sorting and paging functionalities.
func NewPostgresQueryBuilder ¶
NewPostgresQueryBuilder creates a new instance of the query builder with the provided settings.
func (*Builder) AddFilterRequest ¶
AddFilterRequest appends filter conditions to the query builder based on the provided filter request. It constructs conditional clauses using the logic operator specified in the request. TODO: Enhance the AddFilterRequest function to prevent SQL injection vulnerabilities. AddFilterRequest is currently vulnerable to sql injection and should be used only when the input is trusted
func (*Builder) AddPaging ¶
AddPaging appends paging conditions to the query builder based on the provided paging request. It constructs the OFFSET and LIMIT clauses according to the specified page index and page size.
func (*Builder) AddSorting ¶
AddSorting appends sorting conditions to the query builder based on the provided sorting request. It constructs the ORDER BY clause using the specified sort column and direction.
func (*Builder) Build ¶
func (qb *Builder) Build(resultSelector query.ResultSelector) string
Build generates the complete SQL query based on the provided result selector. It constructs the query by adding filter, sorting, and paging conditions. If any error occurs during the construction, it returns an empty string.