Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • v1.6.3
  • v1.6.2
  • v1.6.1
  • v1.6.0
  • v1.5.0
  • v1.4.1
  • v1.4.0
  • v1.3.9
  • v1.3.8
  • v1.3.7
  • v1.3.6
  • v1.3.5
  • v1.3.4
  • v1.3.3
  • v1.3.2
  • v1.3.1
  • v1.3.0
  • v1.2.23
  • v1.2.22
  • v1.2.21
21 results

interfaces.go

basic.go NaN GiB
package postgres

import (
	"github.com/go-pg/pg/v9"
	"gitlab.com/xdevs23/goqlorm/database"
)

type TxMutationAdapter struct {
	tx *pg.Tx
}

func (TxMA TxMutationAdapter) Insert(obj interface{}) error {
	return TxMA.tx.Insert(obj)
}

func (TxMA TxMutationAdapter) Update(obj interface{}) error {
	return TxMA.tx.Update(obj)
}

func (TxMA TxMutationAdapter) Delete(obj interface{}) error {
	return TxMA.tx.Delete(obj)
}

func (db Database) Close() error {
	return db.PgDB.Close()
}

func (db Database) RunInTransaction(fn database.InnerTransactionFunc) error {
	return db.PgDB.RunInTransaction(func(tx *pg.Tx) error {
		return fn(TxMutationAdapter{tx})
	})
}