-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.go
41 lines (33 loc) · 1.21 KB
/
db.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
39
40
41
/*
* Copyright (c) 2024.
* Created by Andy Pangaribuan <https://github.com/apangaribuan>.
*
* This product is protected by copyright and distributed under
* licenses restricting copying, distribution and decompilation.
* All Rights Reserved.
*/
package ice
import "github.com/andypangaribuan/gmod/mol"
type Db interface {
Postgres(conf mol.DbConnection) DbPostgresInstance
PostgresRW(readConf mol.DbConnection, writeConf mol.DbConnection) DbPostgresInstance
}
type DbTx interface {
Commit() error
Rollback() error
}
type DbPostgresInstance interface {
DbInstance
}
type DbInstance interface {
Ping() (string, error)
PingRead() (string, error)
NewTransaction() (DbTx, error)
Select(out any, query string, args ...any) (*mol.DbExecReport, error)
SelectR2(out any, query string, args []any, check *func() bool) (*mol.DbExecReport, error)
Execute(query string, args ...any) (*mol.DbExecReport, error)
ExecuteRID(query string, args ...any) (*int64, *mol.DbExecReport, error)
TxSelect(tx DbTx, out any, query string, args ...any) (*mol.DbExecReport, error)
TxExecute(tx DbTx, query string, args ...any) (*mol.DbExecReport, error)
TxExecuteRID(tx DbTx, query string, args ...any) (*int64, *mol.DbExecReport, error)
}