forked from micro/micro
/
queries.go
38 lines (34 loc) · 1.22 KB
/
queries.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package pgx
import "fmt"
type Queries struct {
// read
ListAsc string
ListAscLimit string
ListDesc string
ListDescLimit string
ReadOne string
ReadManyAsc string
ReadManyAscLimit string
ReadManyDesc string
ReadManyDescLimit string
// change
Write string
Delete string
DeleteExpired string
}
func NewQueries(database, table string) Queries {
return Queries{
ListAsc: fmt.Sprintf(list, database, table) + asc,
ListAscLimit: fmt.Sprintf(list, database, table) + asc + limit,
ListDesc: fmt.Sprintf(list, database, table) + desc,
ListDescLimit: fmt.Sprintf(list, database, table) + desc + limit,
ReadOne: fmt.Sprintf(readOne, database, table),
ReadManyAsc: fmt.Sprintf(readMany, database, table) + asc,
ReadManyAscLimit: fmt.Sprintf(readMany, database, table) + asc + limit,
ReadManyDesc: fmt.Sprintf(readMany, database, table) + desc,
ReadManyDescLimit: fmt.Sprintf(readMany, database, table) + desc + limit,
Write: fmt.Sprintf(write, database, table),
Delete: fmt.Sprintf(deleteRecord, database, table),
DeleteExpired: fmt.Sprintf(deleteExpired, database, table),
}
}