Sync from /srv/compose/unified-media-manager

This commit is contained in:
Christopher Mayor
2026-04-24 10:45:19 -07:00
commit 7dbd00e537
132 changed files with 25394 additions and 0 deletions

41
internal/service/query.go Normal file
View File

@@ -0,0 +1,41 @@
package service
import (
"fmt"
"strings"
)
type QueryBuilder struct {
conditions []string
args []interface{}
idx int
}
func NewQueryBuilder(startIdx int) *QueryBuilder {
return &QueryBuilder{idx: startIdx}
}
func (qb *QueryBuilder) Add(condition string, arg interface{}) {
qb.conditions = append(qb.conditions, fmt.Sprintf(condition, qb.idx))
qb.args = append(qb.args, arg)
qb.idx++
}
func (qb *QueryBuilder) AddLiteral(condition string) {
qb.conditions = append(qb.conditions, condition)
}
func (qb *QueryBuilder) Where() string {
if len(qb.conditions) == 0 {
return ""
}
return " WHERE " + strings.Join(qb.conditions, " AND ")
}
func (qb *QueryBuilder) Args() []interface{} {
return qb.args
}
func (qb *QueryBuilder) Idx() int {
return qb.idx
}