repository

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addresses

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

Addresses is a repository for addresses.

func NewAddressesRepo

func NewAddressesRepo(db *gorm.DB) *Addresses

NewAddressesRepo creates a new repository for addresses.

func (*Addresses) Create

func (r *Addresses) Create(ctx context.Context, newAddress *addressesmodels.NewAddress) error

Create adds a new address to the database.

func (*Addresses) FindByStringAddresses

func (r *Addresses) FindByStringAddresses(ctx context.Context, addresses iter.Seq[string]) ([]addressesmodels.Address, error)

FindByStringAddresses returns address rows from the database based on the provided iterator of string addresses.

type All

type All struct {
	Addresses    *Addresses
	Paymails     *Paymails
	Operations   *Operations
	Transactions *Transactions
	Users        *Users
	Outputs      *Outputs
	Data         *Data
	Contacts     *Contacts
}

All holds all repositories.

func NewRepositories

func NewRepositories(db *gorm.DB) *All

NewRepositories creates a new holder for all repositories.

type Contacts

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

Contacts is a repository for contacts.

func NewContactsRepo

func NewContactsRepo(db *gorm.DB) *Contacts

NewContactsRepo creates a new repository for addresses.

func (*Contacts) Create

Create adds a new contact to the database.

func (*Contacts) Delete

func (r *Contacts) Delete(ctx context.Context, userID, paymail string) error

Delete removes a contact from the database.

func (*Contacts) DeleteByID

func (r *Contacts) DeleteByID(ctx context.Context, contactID uint) error

DeleteByID removes a contact from the database by its ID.

func (*Contacts) Find

func (r *Contacts) Find(ctx context.Context, userID, paymail string) (*contactsmodels.Contact, error)

Find retrieves a contact from the database.

func (*Contacts) FindByID

func (r *Contacts) FindByID(ctx context.Context, contactID uint) (*contactsmodels.Contact, error)

FindByID retrieves a contact from the database by id.

func (*Contacts) PaginatedForAdmin

func (r *Contacts) PaginatedForAdmin(ctx context.Context, page filter.Page, conditions map[string]interface{}) (*models.PagedResult[contactsmodels.Contact], error)

PaginatedForAdmin retrieves contacts for admin and the provided paging options and db conditions.

func (*Contacts) PaginatedForUser

func (r *Contacts) PaginatedForUser(ctx context.Context, userID string, page filter.Page, conditions map[string]interface{}) (*models.PagedResult[contactsmodels.Contact], error)

PaginatedForUser retrieves contacts for user and the provided paging options and db conditions.

func (*Contacts) Update

Update updates contact in database.

func (*Contacts) UpdateByID

func (r *Contacts) UpdateByID(ctx context.Context, contactID uint, fullName string) (*contactsmodels.Contact, error)

UpdateByID updates contact full name using its ID.

func (*Contacts) UpdateStatus

func (r *Contacts) UpdateStatus(ctx context.Context, userID, paymail, status string) error

UpdateStatus updates contact status in database.

func (*Contacts) UpdateStatusByID

func (r *Contacts) UpdateStatusByID(ctx context.Context, contactID uint, status string) (*contactsmodels.Contact, error)

UpdateStatusByID updates contact status using its ID.

type Data

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

Data is a repository for data.

func NewDataRepo

func NewDataRepo(db *gorm.DB) *Data

NewDataRepo creates a new instance of the data repository.

func (*Data) FindForUser

func (r *Data) FindForUser(ctx context.Context, id, userID string) (*datamodels.Data, error)

FindForUser returns the data by outpoint for a specific user.

type Operations

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

Operations is a repository for operations.

func NewOperationsRepo

func NewOperationsRepo(db *gorm.DB) *Operations

NewOperationsRepo creates a new repository for operations.

func (*Operations) PaginatedForUser

func (o *Operations) PaginatedForUser(ctx context.Context, userID string, page filter.Page) (*models.PagedResult[operationsmodels.Operation], error)

PaginatedForUser returns operations for a user based on userID and the provided paging options.

func (*Operations) SaveAll

func (o *Operations) SaveAll(ctx context.Context, operations iter.Seq[*txmodels.NewOperation]) error

SaveAll saves operations to the database.

type Outputs

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

Outputs is a repository for outputs.

func NewOutputsRepo

func NewOutputsRepo(db *gorm.DB) *Outputs

NewOutputsRepo creates a new repository for outputs.

func (*Outputs) FindByOutpoints

func (o *Outputs) FindByOutpoints(ctx context.Context, outpoints iter.Seq[bsv.Outpoint]) ([]txmodels.TrackedOutput, error)

FindByOutpoints returns outputs from the database based on the provided outpoints.

type Paymails

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

Paymails is a repository for paymails.

func NewPaymailsRepo

func NewPaymailsRepo(db *gorm.DB) *Paymails

NewPaymailsRepo creates a new repository for paymails.

func (*Paymails) Create

func (p *Paymails) Create(ctx context.Context, newPaymail *paymailsmodels.NewPaymail) (*paymailsmodels.Paymail, error)

Create adds a new paymail to the database.

func (*Paymails) Find

func (p *Paymails) Find(ctx context.Context, alias, domain string) (*paymailsmodels.Paymail, error)

Find returns a paymail by alias and domain.

func (*Paymails) FindForUser

func (p *Paymails) FindForUser(ctx context.Context, alias, domain, userID string) (*paymailsmodels.Paymail, error)

FindForUser returns a paymail by alias and domain for given user.

func (*Paymails) GetDefault

func (p *Paymails) GetDefault(ctx context.Context, userID string) (*paymailsmodels.Paymail, error)

GetDefault returns a default paymail for user.

type Transactions

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

Transactions provides database operations for managing transactions.

func NewTransactions

func NewTransactions(db *gorm.DB) *Transactions

NewTransactions creates a new Transactions repository. It initializes a database-backed service for querying and managing transactions.

func (*Transactions) FindTransactionInputSources

func (t *Transactions) FindTransactionInputSources(ctx context.Context, sourceTXIDs ...string) (beef.TxQueryResultSlice, error)

FindTransactionInputSources retrieves the full ancestry of input sources for a given transaction. It recursively traces input sources in batches to minimize database queries.

func (*Transactions) GetTransaction

func (t *Transactions) GetTransaction(ctx context.Context, txID string) (transaction *txmodels.TrackedTransaction, err error)

GetTransaction retrieves the tracked transaction with the given transaction ID.

func (*Transactions) HasTransactionInputSources

func (t *Transactions) HasTransactionInputSources(ctx context.Context, sourceTXIDs ...string) (bool, error)

HasTransactionInputSources checks if all the provided input source transaction IDs exist in the database. If all of them are found, the transaction data can be serialized into Raw HEX format. Otherwise, serialization should be done using the BEEFHex format.

func (*Transactions) UpdateTransaction

func (t *Transactions) UpdateTransaction(ctx context.Context, trackedTx *txmodels.TrackedTransaction) error

UpdateTransaction updates the tracked transaction with the given transaction data and makes cleanup of the input sources.

type Users

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

Users is a repository for users.

func NewUsersRepo

func NewUsersRepo(db *gorm.DB) *Users

NewUsersRepo creates a new repository for users.

func (*Users) Create

func (u *Users) Create(ctx context.Context, newUser *usersmodels.NewUser) (*usersmodels.User, error)

Create saves new user to the database.

func (*Users) Delete

func (u *Users) Delete(ctx context.Context, userID string) error

Delete deletes user with userID and deletes their associated paymails, addresses, operations and tracked outputs

func (*Users) Exists

func (u *Users) Exists(ctx context.Context, userID string) (bool, error)

Exists checks if a user exists in the database.

func (*Users) Get

func (u *Users) Get(ctx context.Context, userID string) (*usersmodels.User, error)

Get returns a user by its id with preloaded paymail slist. If the user does not exist, it returns error.

func (*Users) GetBalance

func (u *Users) GetBalance(ctx context.Context, userID string, bucket bucket.Name) (bsv.Satoshis, error)

GetBalance returns the balance of a user in a given bucket.

func (*Users) GetIDByPubKey

func (u *Users) GetIDByPubKey(ctx context.Context, pubKey string) (string, error)

GetIDByPubKey returns a user by its public key. If the user does not exist, it returns error.

Jump to

Keyboard shortcuts

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