db

package
v0.0.0-...-4c8f420 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db struct {
	// contains filtered or unexported fields
}

Db defines the database repository.

func New

func New(config *config.DB, log *logger.AppLogger) *Db

New creates a new database repository.

func (*Db) CurrentEpoch

func (db *Db) CurrentEpoch(ctx context.Context) (uint64, error)

CurrentEpoch returns the current epoch.

func (*Db) DatabaseTransaction

func (db *Db) DatabaseTransaction(ctx context.Context, fn func(context.Context, *Db) error) error

DatabaseTransaction runs the given function in a database transaction.

func (*Db) IncreaseTotalAmountClaimed

func (db *Db) IncreaseTotalAmountClaimed(ctx context.Context, amount *big.Int) error

IncreaseTotalAmountClaimed increases the total amount claimed.

func (*Db) IncreaseTotalAmountCollected

func (db *Db) IncreaseTotalAmountCollected(ctx context.Context, amount *big.Int) error

IncreaseTotalAmountCollected increases the total amount collected.

func (*Db) IncreaseTotalTransactionsCount

func (db *Db) IncreaseTotalTransactionsCount(ctx context.Context, count uint64) error

IncreaseTotalTransactionsCount increases the total number of transactions.

func (*Db) LastProcessedBlock

func (db *Db) LastProcessedBlock(ctx context.Context) (uint64, error)

LastProcessedBlock returns the last processed block.

func (*Db) ProjectContractQuery

func (db *Db) ProjectContractQuery(ctx context.Context) ProjectContractQueryBuilder

ProjectContractQuery returns a new project contract query builder.

func (*Db) ProjectQuery

func (db *Db) ProjectQuery(ctx context.Context) ProjectQueryBuilder

ProjectQuery returns a new project query builder.

func (*Db) SetTotalAmountClaimed

func (db *Db) SetTotalAmountClaimed(ctx context.Context, amount *big.Int) error

SetTotalAmountClaimed sets the total amount claimed.

func (*Db) SetTotalAmountCollected

func (db *Db) SetTotalAmountCollected(ctx context.Context, amount *big.Int) error

SetTotalAmountCollected sets the total amount collected.

func (*Db) SetTotalTransactionsCount

func (db *Db) SetTotalTransactionsCount(ctx context.Context, count uint64) error

SetTotalTransactionsCount sets the total number of transactions.

func (*Db) StoreProject

func (db *Db) StoreProject(ctx context.Context, project *types.Project) error

StoreProject stores the project in the database.

func (*Db) StoreProjectContract

func (db *Db) StoreProjectContract(ctx context.Context, project *types.ProjectContract) error

StoreProjectContract stores the project contract in the database.

func (*Db) StoreTransaction

func (db *Db) StoreTransaction(ctx context.Context, trx *types.Transaction) error

StoreTransaction stores a transaction reference in connected persistent storage.

func (*Db) StoreWithdrawalRequest

func (db *Db) StoreWithdrawalRequest(ctx context.Context, request *types.WithdrawalRequest) error

StoreWithdrawalRequest stores a new withdrawal request into the database.

func (*Db) TotalAmountClaimed

func (db *Db) TotalAmountClaimed(ctx context.Context) (*big.Int, error)

TotalAmountClaimed returns the total amount claimed.

func (*Db) TotalAmountCollected

func (db *Db) TotalAmountCollected(ctx context.Context) (*big.Int, error)

TotalAmountCollected returns the total amount collected.

func (*Db) TotalTransactionsCount

func (db *Db) TotalTransactionsCount(ctx context.Context) (uint64, error)

TotalTransactionsCount returns the total number of transactions.

func (*Db) TransactionQuery

func (db *Db) TransactionQuery(ctx context.Context) TransactionQueryBuilder

TransactionQuery returns a new transaction query builder.

func (*Db) UpdateCurrentEpoch

func (db *Db) UpdateCurrentEpoch(ctx context.Context, epoch uint64) error

UpdateCurrentEpoch updates the current epoch.

func (*Db) UpdateLastProcessedBlock

func (db *Db) UpdateLastProcessedBlock(ctx context.Context, block uint64) error

UpdateLastProcessedBlock updates the last processed block.

func (*Db) UpdateProject

func (db *Db) UpdateProject(ctx context.Context, project *types.Project) error

UpdateProject updates the project in the database.

func (*Db) UpdateWithdrawalRequest

func (db *Db) UpdateWithdrawalRequest(ctx context.Context, request *types.WithdrawalRequest) error

UpdateWithdrawalRequest updates the withdrawal request in the database.

func (*Db) WithdrawalRequestQuery

func (db *Db) WithdrawalRequestQuery(ctx context.Context) WithdrawalRequestQueryBuilder

WithdrawalRequestQuery returns a new withdrawal request query builder.

type ProjectContractQueryBuilder

type ProjectContractQueryBuilder struct {
	// contains filtered or unexported fields
}

func (*ProjectContractQueryBuilder) Delete

func (qb *ProjectContractQueryBuilder) Delete() error

Delete deletes all results of the query.

func (*ProjectContractQueryBuilder) GetAll

func (qb *ProjectContractQueryBuilder) GetAll() ([]T, error)

GetAll returns all results of the query. If no result is found, nil is returned.

func (*ProjectContractQueryBuilder) GetFirst

func (qb *ProjectContractQueryBuilder) GetFirst() (*T, error)

GetFirst returns the first result of the query. If no result is found, nil is returned.

func (*ProjectContractQueryBuilder) GetFirstOrFail

func (qb *ProjectContractQueryBuilder) GetFirstOrFail() (*T, error)

GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.

func (*ProjectContractQueryBuilder) Select

func (qb *ProjectContractQueryBuilder) Select(fields ...string) *queryBuilder[T]

Select sets the fields to select.

func (*ProjectContractQueryBuilder) WhereAddress

WhereAddress adds a where clause to the query builder.

func (*ProjectContractQueryBuilder) WhereId

func (qb *ProjectContractQueryBuilder) WhereId(id int64) *queryBuilder[T]

WhereId adds a where clause to the query builder.

func (*ProjectContractQueryBuilder) WhereIsApproved

func (qb *ProjectContractQueryBuilder) WhereIsApproved(isApproved bool) *ProjectContractQueryBuilder

WhereIsApproved adds a where clause to the query builder.

func (*ProjectContractQueryBuilder) WhereProjectId

func (qb *ProjectContractQueryBuilder) WhereProjectId(projectId int64) *ProjectContractQueryBuilder

WhereProjectId adds a where clause to the query builder.

func (*ProjectContractQueryBuilder) WhereProjectIdIn

func (qb *ProjectContractQueryBuilder) WhereProjectIdIn(ids []int64) *ProjectContractQueryBuilder

WhereProjectIdIn adds a where clause to the query builder.

type ProjectQueryBuilder

type ProjectQueryBuilder struct {
	// contains filtered or unexported fields
}

func (*ProjectQueryBuilder) Delete

func (qb *ProjectQueryBuilder) Delete() error

Delete deletes all results of the query.

func (*ProjectQueryBuilder) GetAll

func (qb *ProjectQueryBuilder) GetAll() ([]T, error)

GetAll returns all results of the query. If no result is found, nil is returned.

func (*ProjectQueryBuilder) GetFirst

func (qb *ProjectQueryBuilder) GetFirst() (*T, error)

GetFirst returns the first result of the query. If no result is found, nil is returned.

func (*ProjectQueryBuilder) GetFirstOrFail

func (qb *ProjectQueryBuilder) GetFirstOrFail() (*T, error)

GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.

func (*ProjectQueryBuilder) Select

func (qb *ProjectQueryBuilder) Select(fields ...string) *queryBuilder[T]

Select sets the fields to select.

func (*ProjectQueryBuilder) WhereActiveInEpoch

func (qb *ProjectQueryBuilder) WhereActiveInEpoch(epoch uint64) *ProjectQueryBuilder

WhereActiveInEpoch adds a where clause to the query builder.

func (*ProjectQueryBuilder) WhereId

func (qb *ProjectQueryBuilder) WhereId(id int64) *queryBuilder[T]

WhereId adds a where clause to the query builder.

func (*ProjectQueryBuilder) WhereOwner

func (qb *ProjectQueryBuilder) WhereOwner(owner *types.Address) *ProjectQueryBuilder

WhereOwner adds a where clause to the query builder.

func (*ProjectQueryBuilder) WhereProjectId

func (qb *ProjectQueryBuilder) WhereProjectId(projectId uint64) *ProjectQueryBuilder

WhereProjectId adds a where clause to the query builder.

type TestDatabase

type TestDatabase struct {
	*Db
	// contains filtered or unexported fields
}

func SetupTestDatabase

func SetupTestDatabase(logger *logger.AppLogger) *TestDatabase

SetupTestDatabase creates a test container for postgres database and returns a database instance

func (*TestDatabase) Drop

func (tdb *TestDatabase) Drop() error

Drop drops all tables

func (*TestDatabase) Migrate

func (tdb *TestDatabase) Migrate() error

Migrate runs the database migrations

func (*TestDatabase) TearDown

func (tdb *TestDatabase) TearDown()

TearDown removes the test container and closes the database connection

type TransactionQueryBuilder

type TransactionQueryBuilder struct {
	// contains filtered or unexported fields
}

func (*TransactionQueryBuilder) Delete

func (qb *TransactionQueryBuilder) Delete() error

Delete deletes all results of the query.

func (*TransactionQueryBuilder) GetAll

func (qb *TransactionQueryBuilder) GetAll() ([]T, error)

GetAll returns all results of the query. If no result is found, nil is returned.

func (*TransactionQueryBuilder) GetFirst

func (qb *TransactionQueryBuilder) GetFirst() (*T, error)

GetFirst returns the first result of the query. If no result is found, nil is returned.

func (*TransactionQueryBuilder) GetFirstOrFail

func (qb *TransactionQueryBuilder) GetFirstOrFail() (*T, error)

GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.

func (*TransactionQueryBuilder) Select

func (qb *TransactionQueryBuilder) Select(fields ...string) *queryBuilder[T]

Select sets the fields to select.

func (*TransactionQueryBuilder) WhereEpoch

WhereEpoch adds a where clause to the query builder.

func (*TransactionQueryBuilder) WhereEpochLt

func (qb *TransactionQueryBuilder) WhereEpochLt(epoch uint64) *TransactionQueryBuilder

WhereEpochLt adds a where clause to the query builder.

func (*TransactionQueryBuilder) WhereId

func (qb *TransactionQueryBuilder) WhereId(id int64) *queryBuilder[T]

WhereId adds a where clause to the query builder.

func (*TransactionQueryBuilder) WhereProjectId

func (qb *TransactionQueryBuilder) WhereProjectId(id int64) *TransactionQueryBuilder

WhereProjectId adds a where clause to the query builder.

type WithdrawalRequestQueryBuilder

type WithdrawalRequestQueryBuilder struct {
	// contains filtered or unexported fields
}

func (*WithdrawalRequestQueryBuilder) Delete

func (qb *WithdrawalRequestQueryBuilder) Delete() error

Delete deletes all results of the query.

func (*WithdrawalRequestQueryBuilder) GetAll

func (qb *WithdrawalRequestQueryBuilder) GetAll() ([]T, error)

GetAll returns all results of the query. If no result is found, nil is returned.

func (*WithdrawalRequestQueryBuilder) GetFirst

func (qb *WithdrawalRequestQueryBuilder) GetFirst() (*T, error)

GetFirst returns the first result of the query. If no result is found, nil is returned.

func (*WithdrawalRequestQueryBuilder) GetFirstOrFail

func (qb *WithdrawalRequestQueryBuilder) GetFirstOrFail() (*T, error)

GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.

func (*WithdrawalRequestQueryBuilder) Select

func (qb *WithdrawalRequestQueryBuilder) Select(fields ...string) *queryBuilder[T]

Select sets the fields to select.

func (*WithdrawalRequestQueryBuilder) WhereId

func (qb *WithdrawalRequestQueryBuilder) WhereId(id int64) *queryBuilder[T]

WhereId adds a where clause to the query builder.

func (*WithdrawalRequestQueryBuilder) WhereProjectId

func (qb *WithdrawalRequestQueryBuilder) WhereProjectId(projectId int64) *WithdrawalRequestQueryBuilder

WhereProjectId adds a where clause to the query builder.

func (*WithdrawalRequestQueryBuilder) WhereRequestEpoch

WhereRequestEpoch adds a where clause to the query builder.

func (*WithdrawalRequestQueryBuilder) WhereWithdrawEpoch

WhereWithdrawEpoch adds a where clause to the query builder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL