storj/pkg/satellite/database.go
Yehor Butko 678eb81d54
V3-898 Create ability for querying db in transaction scope (#781)
* V3-898 Create ability for querying db in transaction scope

* handling errors

* fixing linter

* Transaction updated

* fixing empty lines linter

* tx signatures changed

* fixing comments
2018-12-10 14:29:01 +02:00

36 lines
997 B
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package satellite
import "context"
// DB contains access to different satellite databases
type DB interface {
// Users is a getter for Users repository
Users() Users
// Companies is a getter for Companies repository
Companies() Companies
// Projects is a getter for Projects repository
Projects() Projects
// ProjectMembers is a getter for ProjectMembers repository
ProjectMembers() ProjectMembers
// CreateTables is a method for creating all tables for satellitedb
CreateTables() error
// Close is used to close db connection
Close() error
// BeginTransaction is a method for opening transaction
BeginTx(ctx context.Context) (DBTx, error)
}
// DBTx extends Database with transaction scope
type DBTx interface {
DB
// CommitTransaction is a method for committing and closing transaction
Commit() error
// RollbackTransaction is a method for rollback and closing transaction
Rollback() error
}