Documentation
¶
Overview ¶
package workshop provides a simple interface to build a where query for any database in a simple filter-style manner.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Condition ¶
Condition is a struct that holds a single condition for a query. It is made of a column, an operator and a value. For some operators, the value may be superfluous.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a struct that holds the conditions for a query. It can be used to build a query for any database. It is thread-safe. It uses the builder pattern.
func (*Filter) And ¶
And adds a condition to the filter. It is thread-safe. It uses the builder pattern. It returns the Filter itself. It always adds the condition to the last group. If there is no group, it creates one.
func (*Filter) Or ¶
Or adds a condition to the filter. It is thread-safe. It uses the builder pattern. It returns the Filter itself. It always adds the condition to a new group.
func (*Filter) Transform ¶
func (f *Filter) Transform(t Transformer) []any
Transform applies the given Transformer to the filter's groups and returns the final query as per the transformer's implementation. It is thread-safe.
type Group ¶
type Group []Condition
Group is a collection of conditions that have an AND relationship.
type Transformer ¶
Transformer is a function that receives groups of conditions and returns the query and its values as they may be used in a prepared statement.