-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx.go
44 lines (33 loc) · 1 KB
/
tx.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
42
43
44
package pg
import "database/sql"
// Tx implements the EntityHandler and the ResultHandler interfaces
type Tx struct {
tx *sql.Tx
}
func (t *Tx) Commit() error {
return t.tx.Commit()
}
func (t *Tx) Rollback() error {
return t.tx.Rollback()
}
func (t *Tx) Create(entity Entity) error {
return create(t.tx, entity)
}
func (t *Tx) FindOne(entity Entity, where string, whereParams ...interface{}) (Entity, error) {
return findOne(t.tx, entity, where, whereParams...)
}
func (t *Tx) FindAll(entity Entity, where string, whereParams ...interface{}) ([]Entity, error) {
return findAll(t.tx, entity, where, whereParams...)
}
func (t *Tx) Update(entity Entity) error {
return update(t.tx, entity)
}
func (t *Tx) Delete(entity Entity) error {
return delete(t.tx, entity)
}
func (t *Tx) Query(result Result, sql string, params ...interface{}) ([]Result, error) {
return query(t.tx, result, sql, params...)
}
func (t *Tx) Exec(query string, args ...interface{}) (sql.Result, error) {
return exec(t.tx, query, args...)
}