misc.go 533 Bytes
Newer Older
Vladimir Barsukov's avatar
Vladimir Barsukov committed
1
2
3
4
5
package zdb

import (
	"errors"
	"github.com/jackc/pgx/v5"
Vladimir Barsukov's avatar
zgo    
Vladimir Barsukov committed
6
	"strings"
Vladimir Barsukov's avatar
Vladimir Barsukov committed
7
8
9
10
11
12
13
14
15
16
17
18
)

var ErrNoRows = pgx.ErrNoRows

func IsEmpty(err error) bool {
	return errors.Is(err, ErrNoRows)
}

type Opts interface {
	Opts() (sql string, args map[string]any)
}

Vladimir Barsukov's avatar
zgo    
Vladimir Barsukov committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
func remove[T comparable](slice []T, s int) []T {
	return append(slice[:s], slice[s+1:]...)
}

func contains(s string, sl []string) bool {
	for _, s2 := range sl {
		if strings.Contains(s, s2) {
			return true
		}
	}

	return false
}

Vladimir Barsukov's avatar
Vladimir Barsukov committed
33
34
35
type Logger interface {
	Printf(format string, v ...any)
}