func (o OrderByQuery) Desc() OrderByQuery {
	return OrderByQuery{
		fields: o.fields,
		desc:   true,
	}
}
Desc is a setter function for configuring the
ORDER BY part of the query as DESC
package kbuilder
import (
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"github.com/pkg/errors"
	"github.com/vingarcia/ksql"
	"github.com/vingarcia/ksql/kstructs"
)
type Query struct {
	Select interface{}
	From string
	Where WhereQueries
	Limit   int
	Offset  int
	OrderBy OrderByQuery
}
func (q Query) Build(driver string) (sqlQuery string, params []interface{}, _ error) {
	dialect, err := ksql.GetDriverDialect(driver)
	if err != nil {
		return "", nil, err
	}
	return q.BuildQuery(dialect)
}
func (q Query) BuildQuery(dialect ksql.Dialect) (sqlQuery string, params []interface{}, _ error) {
	var b strings.Builder
	switch v := q.Select.(type) {
	case string:
		b.WriteString("SELECT " + v)
	default:
		selectQuery, err := buildSelectQuery(v, dialect)
		if err != nil {
			return "", nil, errors.Wrap(err, "error reading the Select field")
		}
		b.WriteString("SELECT " + selectQuery)
	}
	b.WriteString(" FROM " + q.From)
	if len(q.Where) > 0 {
		var whereQuery string
		whereQuery, params = q.Where.build(dialect)
		b.WriteString(" WHERE " + whereQuery)
	}
	if strings.TrimSpace(q.From) == "" {
		return "", nil, fmt.Errorf("the From field is mandatory for every query")
	}
	if q.OrderBy.fields != "" {
		b.WriteString(" ORDER BY " + q.OrderBy.fields)
		if q.OrderBy.desc {
			b.WriteString(" DESC")
		}
	}
	if q.Limit > 0 {
		b.WriteString(" LIMIT " + strconv.Itoa(q.Limit))
	}
	if q.Offset > 0 {
		b.WriteString(" OFFSET " + strconv.Itoa(q.Offset))
	}
	return b.String(), params, nil
}
type WhereQuery struct {
	cond   string
	params []interface{}
}
type WhereQueries []WhereQuery
func (w WhereQueries) build(dialect ksql.Dialect) (query string, params []interface{}) {
	var conds []string
	for _, whereQuery := range w {
		var placeholders []interface{}
		for i := range whereQuery.params {
			placeholders = append(placeholders, dialect.Placeholder(len(params)+i))
		}
		conds = append(conds, fmt.Sprintf(whereQuery.cond, placeholders...))
		params = append(params, whereQuery.params...)
	}
	return strings.Join(conds, " AND "), params
}
func (w WhereQueries) Where(cond string, params ...interface{}) WhereQueries {
	return append(w, WhereQuery{
		cond:   cond,
		params: params,
	})
}
func (w WhereQueries) WhereIf(cond string, param interface{}) WhereQueries {
	if param == nil || reflect.ValueOf(param).IsNil() {
		return w
	}
	return append(w, WhereQuery{
		cond:   cond,
		params: []interface{}{param},
	})
}
func Where(cond string, params ...interface{}) WhereQueries {
	return WhereQueries{{
		cond:   cond,
		params: params,
	}}
}
func WhereIf(cond string, param interface{}) WhereQueries {
	if param == nil || reflect.ValueOf(param).IsNil() {
		return WhereQueries{}
	}
	return WhereQueries{{
		cond:   cond,
		params: []interface{}{param},
	}}
}
type OrderByQuery struct {
	fields string
	desc   bool
}