Documentation
¶
Index ¶
- func LimitOffset(limit int, offset int) string
- type QueryBuilder
- func (b *QueryBuilder) Delete(filters *filters.Filters) (string, error)
- func (b *QueryBuilder) DeleteReturningID(filters *filters.Filters) (string, error)
- func (b *QueryBuilder) Select(order []string, limit int, offset int, filters *filters.Filters) (string, error)
- func (b *QueryBuilder) SelectCount(filters *filters.Filters) (string, error)
- func (b *QueryBuilder) Update(values map[string]interface{}, filters *filters.Filters) (string, error)
- type QueryBuilderError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitOffset ¶
LimitOffset returns a LIMIT and OFFSET clause for a query.
Types ¶
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
func New ¶
func New(structInfo *structinfo.StructInfo, queryContainer *postgresQueryContainer.QueryContainer) *QueryBuilder
func (*QueryBuilder) Delete ¶
func (b *QueryBuilder) Delete(filters *filters.Filters) (string, error)
Delete returns a DELETE query with a WHERE condition built from 'filters' (field-value pairs). Struct fields in the 'filters' argument are sorted alphabetically. Hence, when used with a database connection, their values (or pointers to it) must be sorted as well.
func (*QueryBuilder) DeleteReturningID ¶
func (b *QueryBuilder) DeleteReturningID(filters *filters.Filters) (string, error)
DeleteReturningID returns a DELETE query with a WHERE condition built from 'filters' (field-value pairs) with RETURNING id. Struct fields in the 'filters' argument are sorted alphabetically. Hence, when used with a database connection, their values (or pointers to it) must be sorted as well.
func (*QueryBuilder) Select ¶
func (b *QueryBuilder) Select(order []string, limit int, offset int, filters *filters.Filters) (string, error)
Select returns a SELECT query with a WHERE condition built from 'filters' (field-value pairs). Struct fields in the 'filters' argument are sorted alphabetically. Hence, when used with a database connection, their values (or pointers to it) must be sorted as well. Columns in the SELECT query are ordered the same way as they are defined in the struct: SELECT field1_column, field2_column, ... etc.
func (*QueryBuilder) SelectCount ¶
func (b *QueryBuilder) SelectCount(filters *filters.Filters) (string, error)
SelectCount returns a SELECT COUNT(*) query to count rows with a WHERE condition built from 'filters' (field-value pairs). Struct fields in the 'filters' argument are sorted alphabetically. Hence, when used with a database connection, their values (or pointers to it) must be sorted as well.
func (*QueryBuilder) Update ¶
func (b *QueryBuilder) Update(values map[string]interface{}, filters *filters.Filters) (string, error)
Update returns an UPDATE query where specified struct fields (columns) are updated and rows match specific WHERE condition built from 'filters' (field-value pairs). Struct fields in 'values' and the 'filters' arguments are sorted alphabetically. Hence, when used with a database connection, their values (or pointers to it) must be sorted as well.
type QueryBuilderError ¶
func (*QueryBuilderError) Error ¶
func (e *QueryBuilderError) Error() string