refactor with improved developer ux in mind

- Most functions now live directly in the dbx package
- dbxp and dbxm are now ONLY the few functions that cannot be shared
This commit is contained in:
Elijah Duffy
2025-06-12 17:44:44 -07:00
parent 18e669101e
commit 32567471e1
7 changed files with 332 additions and 357 deletions

View File

@@ -1,9 +1,25 @@
package dbx
import (
"strings"
"github.com/go-jet/jet/v2/mysql"
)
// StringToFilter processes a string to be used as a filter in an SQL LIKE
// statement. It replaces all spaces with % and adds % to the beginning and
// end of the string.
func StringToFilter(str string) string {
// Remove any existing leading or trailing % characters
str = strings.Trim(str, "%")
// Replace all spaces with % and add % to the beginning and end of the string
str = strings.ReplaceAll(str, " ", "%")
str = "%" + str + "%"
return str
}
// ExprID converts a list of uint64 values to a list of mysql.Expression values
func ExprID(ids []uint64) []mysql.Expression {
expressions := make([]mysql.Expression, len(ids))