sqlite

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	ID      int       // The unique sequence ID of the migration
	Name    string    // The human readable name of the migration
	Version string    // The package version when the migration was applied
	Created time.Time // The timestamp when the migration was applied
	Path    string    // The path of the migration in the filesystem
}

Migration is used to represent both a SQL migration from the embedded file system and a migration record in the database. These records are compared to ensure the database is as up to date as possible before the application starts.

func Migrations

func Migrations() (data []*Migration, err error)

Migrations returns the migration files from the embedded file system.

func (*Migration) SQL

func (m *Migration) SQL() (_ string, err error)

SQL loads the schema sql query from the embedded file on disk.

type PreparedTransaction

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

func (*PreparedTransaction) AddCounterparty

func (p *PreparedTransaction) AddCounterparty(in *models.Counterparty) (err error)

TODO: this method needs to be tested extensively!!

func (*PreparedTransaction) AddEnvelope

func (p *PreparedTransaction) AddEnvelope(in *models.SecureEnvelope) (err error)

func (*PreparedTransaction) Commit

func (p *PreparedTransaction) Commit() error

func (*PreparedTransaction) CreateSunrise added in v0.28.0

func (p *PreparedTransaction) CreateSunrise(in *models.Sunrise) error

func (*PreparedTransaction) Created

func (p *PreparedTransaction) Created() bool

func (*PreparedTransaction) Fetch

func (p *PreparedTransaction) Fetch() (transaction *models.Transaction, err error)

func (*PreparedTransaction) LookupCounterparty added in v0.30.0

func (p *PreparedTransaction) LookupCounterparty(field, value string) (*models.Counterparty, error)

func (*PreparedTransaction) Rollback

func (p *PreparedTransaction) Rollback() error

func (*PreparedTransaction) Update

func (p *PreparedTransaction) Update(in *models.Transaction) (err error)

func (*PreparedTransaction) UpdateCounterparty added in v0.28.0

func (p *PreparedTransaction) UpdateCounterparty(in *models.Counterparty) (err error)

func (*PreparedTransaction) UpdateSunrise added in v0.28.0

func (p *PreparedTransaction) UpdateSunrise(in *models.Sunrise) error

type Store

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

Store implements the store.Store interface using SQLite3 as the storage backend.

func Open

func Open(uri *dsn.DSN) (_ *Store, err error)

func (*Store) ArchiveTransaction added in v0.29.0

func (s *Store) ArchiveTransaction(ctx context.Context, transactionID uuid.UUID) (err error)

func (*Store) BeginTx

func (s *Store) BeginTx(ctx context.Context, opts *sql.TxOptions) (tx *sql.Tx, err error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateAPIKey

func (s *Store) CreateAPIKey(ctx context.Context, key *models.APIKey) (err error)

func (*Store) CreateAccount

func (s *Store) CreateAccount(ctx context.Context, account *models.Account) (err error)

Create an account and any crypto addresses associated with the account.

func (*Store) CreateContact added in v0.28.0

func (s *Store) CreateContact(ctx context.Context, contact *models.Contact) (err error)

func (*Store) CreateCounterparty

func (s *Store) CreateCounterparty(ctx context.Context, counterparty *models.Counterparty) (err error)

func (*Store) CreateCryptoAddress

func (s *Store) CreateCryptoAddress(ctx context.Context, addr *models.CryptoAddress) (err error)

func (*Store) CreateSecureEnvelope

func (s *Store) CreateSecureEnvelope(ctx context.Context, env *models.SecureEnvelope) (err error)

func (*Store) CreateSunrise added in v0.28.0

func (s *Store) CreateSunrise(ctx context.Context, msg *models.Sunrise) (err error)

Create a sunrise message in the database.

func (*Store) CreateTransaction

func (s *Store) CreateTransaction(ctx context.Context, transaction *models.Transaction) (err error)

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, user *models.User) (err error)

func (*Store) DeleteAPIKey

func (s *Store) DeleteAPIKey(ctx context.Context, keyID ulid.ULID) (err error)

func (*Store) DeleteAccount

func (s *Store) DeleteAccount(ctx context.Context, id ulid.ULID) (err error)

Delete account and all associated crypto addresses

func (*Store) DeleteContact added in v0.28.0

func (s *Store) DeleteContact(ctx context.Context, contactID, counterpartyID ulid.ULID) (err error)

func (*Store) DeleteCounterparty

func (s *Store) DeleteCounterparty(ctx context.Context, counterpartyID ulid.ULID) (err error)

func (*Store) DeleteCryptoAddress

func (s *Store) DeleteCryptoAddress(ctx context.Context, accountID, cryptoAddressID ulid.ULID) (err error)

func (*Store) DeleteSecureEnvelope

func (s *Store) DeleteSecureEnvelope(ctx context.Context, txID uuid.UUID, envID ulid.ULID) (err error)

func (*Store) DeleteSunrise added in v0.28.0

func (s *Store) DeleteSunrise(ctx context.Context, id ulid.ULID) (err error)

Delete sunrise message from the database.

func (*Store) DeleteTransaction

func (s *Store) DeleteTransaction(ctx context.Context, id uuid.UUID) (err error)

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, userID ulid.ULID) (err error)

func (*Store) GetOrCreateSunriseCounterparty added in v0.28.0

func (s *Store) GetOrCreateSunriseCounterparty(ctx context.Context, email, name string) (out *models.Counterparty, err error)

Get or create a sunrise counterparty from an email address.

func (*Store) InitializeSchema

func (s *Store) InitializeSchema(empty bool) (err error)

Initialize schema applies any unapplied migrations to the database and should be run when the database is first connected to. If empty is true then the migration table is created and all migrations are applied. If it is not true then the current migration of the database is fetched and all unapplied migrations are applied.

This method is called on Open() and should not be directly applied by the user.

func (*Store) LatestPayloadEnvelope added in v0.24.0

func (s *Store) LatestPayloadEnvelope(ctx context.Context, envelopeID uuid.UUID, direction string) (env *models.SecureEnvelope, err error)

func (*Store) LatestSecureEnvelope added in v0.14.0

func (s *Store) LatestSecureEnvelope(ctx context.Context, envelopeID uuid.UUID, direction string) (env *models.SecureEnvelope, err error)

func (*Store) ListAPIKeys

func (s *Store) ListAPIKeys(ctx context.Context, page *models.PageInfo) (out *models.APIKeyPage, err error)

func (*Store) ListAccounts

func (s *Store) ListAccounts(ctx context.Context, page *models.PageInfo) (out *models.AccountsPage, err error)

Retrieve summary information for all accounts for the specified page, omitting crypto addresses and any other irrelevant information.

func (*Store) ListContacts added in v0.28.0

func (s *Store) ListContacts(ctx context.Context, counterpartyID ulid.ULID, page *models.PageInfo) (out *models.ContactsPage, err error)

List contacts associated with the specified counterparty.

func (*Store) ListCounterparties

func (s *Store) ListCounterparties(ctx context.Context, page *models.PageInfo) (out *models.CounterpartyPage, err error)

func (*Store) ListCounterpartySourceInfo

func (s *Store) ListCounterpartySourceInfo(ctx context.Context, source string) (out []*models.CounterpartySourceInfo, err error)

func (*Store) ListCryptoAddresses

func (s *Store) ListCryptoAddresses(ctx context.Context, accountID ulid.ULID, page *models.PageInfo) (out *models.CryptoAddressPage, err error)

List crypto addresses associated with the specified accountID.

func (*Store) ListSecureEnvelopes

func (s *Store) ListSecureEnvelopes(ctx context.Context, txID uuid.UUID, page *models.PageInfo) (out *models.SecureEnvelopePage, err error)

func (*Store) ListSunrise added in v0.28.0

func (s *Store) ListSunrise(ctx context.Context, page *models.PageInfo) (out *models.SunrisePage, err error)

Retrieve sunrise messages from the database and return them as a paginated list.

func (*Store) ListTransactions

func (s *Store) ListTransactions(ctx context.Context, page *models.PageInfo) (out *models.TransactionPage, err error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, page *models.PageInfo) (out *models.UserPage, err error)

func (*Store) LookupCounterparty

func (s *Store) LookupCounterparty(ctx context.Context, field, value string) (counterparty *models.Counterparty, err error)

func (*Store) LookupRole added in v0.18.0

func (s *Store) LookupRole(ctx context.Context, role string) (model *models.Role, err error)

func (*Store) PrepareTransaction

func (s *Store) PrepareTransaction(ctx context.Context, envelopeID uuid.UUID) (_ models.PreparedTransaction, err error)

func (*Store) RetrieveAPIKey

func (s *Store) RetrieveAPIKey(ctx context.Context, clientIDOrKeyID any) (key *models.APIKey, err error)

func (*Store) RetrieveAccount

func (s *Store) RetrieveAccount(ctx context.Context, id ulid.ULID) (account *models.Account, err error)

Retrieve account detail information including all associated crypto addresses.

func (*Store) RetrieveContact added in v0.28.0

func (s *Store) RetrieveContact(ctx context.Context, contactID, counterpartyID ulid.ULID) (contact *models.Contact, err error)

func (*Store) RetrieveCounterparty

func (s *Store) RetrieveCounterparty(ctx context.Context, counterpartyID ulid.ULID) (counterparty *models.Counterparty, err error)

func (*Store) RetrieveCryptoAddress

func (s *Store) RetrieveCryptoAddress(ctx context.Context, accountID, cryptoAddressID ulid.ULID) (addr *models.CryptoAddress, err error)

func (*Store) RetrieveSecureEnvelope

func (s *Store) RetrieveSecureEnvelope(ctx context.Context, txID uuid.UUID, envID ulid.ULID) (env *models.SecureEnvelope, err error)

func (*Store) RetrieveSunrise added in v0.28.0

func (s *Store) RetrieveSunrise(ctx context.Context, id ulid.ULID) (msg *models.Sunrise, err error)

Retrieve sunrise message detail information.

func (*Store) RetrieveTransaction

func (s *Store) RetrieveTransaction(ctx context.Context, id uuid.UUID) (transaction *models.Transaction, err error)

func (*Store) RetrieveUser

func (s *Store) RetrieveUser(ctx context.Context, emailOrUserID any) (user *models.User, err error)

func (*Store) SearchCounterparties added in v0.23.0

func (s *Store) SearchCounterparties(ctx context.Context, query *models.SearchQuery) (out *models.CounterpartyPage, err error)

func (*Store) SetUserLastLogin added in v0.18.0

func (s *Store) SetUserLastLogin(ctx context.Context, userID ulid.ULID, lastLogin time.Time) (err error)

func (*Store) SetUserPassword

func (s *Store) SetUserPassword(ctx context.Context, userID ulid.ULID, password string) (err error)

func (*Store) Stats added in v0.28.0

func (s *Store) Stats() sql.DBStats

func (*Store) UpdateAPIKey

func (s *Store) UpdateAPIKey(ctx context.Context, key *models.APIKey) (err error)

NOTE: the only thing that can be updated on an api key right now is last_seen

func (*Store) UpdateAccount

func (s *Store) UpdateAccount(ctx context.Context, a *models.Account) (err error)

Update account information; ignores any associated crypto addresses.

func (*Store) UpdateContact added in v0.28.0

func (s *Store) UpdateContact(ctx context.Context, contact *models.Contact) (err error)

func (*Store) UpdateCounterparty

func (s *Store) UpdateCounterparty(ctx context.Context, counterparty *models.Counterparty) (err error)

func (*Store) UpdateCryptoAddress

func (s *Store) UpdateCryptoAddress(ctx context.Context, addr *models.CryptoAddress) (err error)

func (*Store) UpdateSecureEnvelope

func (s *Store) UpdateSecureEnvelope(ctx context.Context, env *models.SecureEnvelope) (err error)

func (*Store) UpdateSunrise added in v0.28.0

func (s *Store) UpdateSunrise(ctx context.Context, msg *models.Sunrise) (err error)

Update sunrise message information.

func (*Store) UpdateTransaction

func (s *Store) UpdateTransaction(ctx context.Context, t *models.Transaction) (err error)

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, user *models.User) (err error)

func (*Store) UseTravelAddressFactory

func (s *Store) UseTravelAddressFactory(f models.TravelAddressFactory)

Jump to

Keyboard shortcuts

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