Documentation ¶
Overview ¶
Package mysql provides an interface for writing to a MySQL instance.
Index ¶
- Variables
- func ProvideDatabaseClient(ctx context.Context, logger logging.Logger, cfg *dbconfig.Config, ...) (database.DataManager, error)
- type SQLQuerier
- func (q *SQLQuerier) AddUserToAccount(ctx context.Context, input *types.AddUserToAccountInput) error
- func (q *SQLQuerier) ArchiveAPIClient(ctx context.Context, clientID, userID string) error
- func (q *SQLQuerier) ArchiveAccount(ctx context.Context, accountID, userID string) error
- func (q *SQLQuerier) ArchiveItem(ctx context.Context, itemID, accountID string) error
- func (q *SQLQuerier) ArchiveUser(ctx context.Context, userID string) error
- func (q *SQLQuerier) ArchiveWebhook(ctx context.Context, webhookID, accountID string) error
- func (q *SQLQuerier) BuildSessionContextDataForUser(ctx context.Context, userID string) (*types.SessionContextData, error)
- func (q *SQLQuerier) CreateAPIClient(ctx context.Context, input *types.APIClientCreationInput) (*types.APIClient, error)
- func (q *SQLQuerier) CreateAccount(ctx context.Context, input *types.AccountCreationInput) (*types.Account, error)
- func (q *SQLQuerier) CreateItem(ctx context.Context, input *types.ItemDatabaseCreationInput) (*types.Item, error)
- func (q *SQLQuerier) CreateUser(ctx context.Context, input *types.UserDataStoreCreationInput) (*types.User, error)
- func (q *SQLQuerier) CreateWebhook(ctx context.Context, input *types.WebhookDatabaseCreationInput) (*types.Webhook, error)
- func (q *SQLQuerier) GetAPIClientByClientID(ctx context.Context, clientID string) (*types.APIClient, error)
- func (q *SQLQuerier) GetAPIClientByDatabaseID(ctx context.Context, clientID, userID string) (*types.APIClient, error)
- func (q *SQLQuerier) GetAPIClients(ctx context.Context, userID string, filter *types.QueryFilter) (x *types.APIClientList, err error)
- func (q *SQLQuerier) GetAccount(ctx context.Context, accountID, userID string) (*types.Account, error)
- func (q *SQLQuerier) GetAccounts(ctx context.Context, userID string, filter *types.QueryFilter) (x *types.AccountList, err error)
- func (q *SQLQuerier) GetAccountsForAdmin(ctx context.Context, filter *types.QueryFilter) (x *types.AccountList, err error)
- func (q *SQLQuerier) GetAllAccountsCount(ctx context.Context) (uint64, error)
- func (q *SQLQuerier) GetAllUsersCount(ctx context.Context) (uint64, error)
- func (q *SQLQuerier) GetAllWebhooksCount(ctx context.Context) (uint64, error)
- func (q *SQLQuerier) GetDefaultAccountIDForUser(ctx context.Context, userID string) (string, error)
- func (q *SQLQuerier) GetItem(ctx context.Context, itemID, accountID string) (*types.Item, error)
- func (q *SQLQuerier) GetItems(ctx context.Context, accountID string, filter *types.QueryFilter) (x *types.ItemList, err error)
- func (q *SQLQuerier) GetItemsWithIDs(ctx context.Context, accountID string, limit uint8, ids []string) ([]*types.Item, error)
- func (q *SQLQuerier) GetTotalAPIClientCount(ctx context.Context) (uint64, error)
- func (q *SQLQuerier) GetTotalItemCount(ctx context.Context) (uint64, error)
- func (q *SQLQuerier) GetUser(ctx context.Context, userID string) (*types.User, error)
- func (q *SQLQuerier) GetUserByUsername(ctx context.Context, username string) (*types.User, error)
- func (q *SQLQuerier) GetUserWithUnverifiedTwoFactorSecret(ctx context.Context, userID string) (*types.User, error)
- func (q *SQLQuerier) GetUsers(ctx context.Context, filter *types.QueryFilter) (x *types.UserList, err error)
- func (q *SQLQuerier) GetWebhook(ctx context.Context, webhookID, accountID string) (*types.Webhook, error)
- func (q *SQLQuerier) GetWebhooks(ctx context.Context, accountID string, filter *types.QueryFilter) (*types.WebhookList, error)
- func (q *SQLQuerier) IsReady(ctx context.Context, maxAttempts uint8) (ready bool)
- func (q *SQLQuerier) ItemExists(ctx context.Context, itemID, accountID string) (exists bool, err error)
- func (q *SQLQuerier) MarkAccountAsUserDefault(ctx context.Context, userID, accountID string) error
- func (q *SQLQuerier) MarkUserTwoFactorSecretAsVerified(ctx context.Context, userID string) error
- func (q *SQLQuerier) Migrate(ctx context.Context, maxAttempts uint8, ...) error
- func (q *SQLQuerier) ModifyUserPermissions(ctx context.Context, accountID, userID string, ...) error
- func (q *SQLQuerier) ProvideSessionStore() scs.Store
- func (q *SQLQuerier) RemoveUserFromAccount(ctx context.Context, userID, accountID string) error
- func (q *SQLQuerier) SearchForUsersByUsername(ctx context.Context, usernameQuery string) ([]*types.User, error)
- func (q *SQLQuerier) TransferAccountOwnership(ctx context.Context, accountID string, ...) error
- func (q *SQLQuerier) UpdateAccount(ctx context.Context, updated *types.Account) error
- func (q *SQLQuerier) UpdateItem(ctx context.Context, updated *types.Item) error
- func (q *SQLQuerier) UpdateUser(ctx context.Context, updated *types.User) error
- func (q *SQLQuerier) UpdateUserPassword(ctx context.Context, userID, newHash string) error
- func (q *SQLQuerier) UpdateUserReputation(ctx context.Context, userID string, input *types.UserReputationUpdateInput) error
- func (q *SQLQuerier) UpdateUserTwoFactorSecret(ctx context.Context, userID, newSecret string) error
- func (q *SQLQuerier) UserHasStatus(ctx context.Context, userID string, statuses ...string) (banned bool, err error)
- func (q *SQLQuerier) UserIsMemberOfAccount(ctx context.Context, userID, accountID string) (bool, error)
- func (q *SQLQuerier) WebhookExists(ctx context.Context, webhookID, accountID string) (exists bool, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilInputProvided indicates nil input was provided in an unacceptable context. ErrNilInputProvided = errors.New("nil input provided") // ErrNilTransactionProvided indicates nil transaction was provided in an unacceptable context. ErrNilTransactionProvided = errors.New("empty input provided") // ErrEmptyInputProvided indicates empty input was provided in an unacceptable context. ErrEmptyInputProvided = errors.New("empty input provided") // ErrInvalidIDProvided indicates a required ID was passed in as zero. ErrInvalidIDProvided = errors.New("required ID provided is zero") )
Functions ¶
Types ¶
type SQLQuerier ¶
type SQLQuerier struct {
// contains filtered or unexported fields
}
SQLQuerier is the primary database querying client. All tracing/logging/query execution happens here. Query building generally happens elsewhere.
func (*SQLQuerier) AddUserToAccount ¶
func (q *SQLQuerier) AddUserToAccount(ctx context.Context, input *types.AddUserToAccountInput) error
AddUserToAccount does a thing.
func (*SQLQuerier) ArchiveAPIClient ¶
func (q *SQLQuerier) ArchiveAPIClient(ctx context.Context, clientID, userID string) error
ArchiveAPIClient archives an API client.
func (*SQLQuerier) ArchiveAccount ¶
func (q *SQLQuerier) ArchiveAccount(ctx context.Context, accountID, userID string) error
ArchiveAccount archives an account from the database by its ID.
func (*SQLQuerier) ArchiveItem ¶
func (q *SQLQuerier) ArchiveItem(ctx context.Context, itemID, accountID string) error
ArchiveItem archives an item from the database by its ID.
func (*SQLQuerier) ArchiveUser ¶
func (q *SQLQuerier) ArchiveUser(ctx context.Context, userID string) error
ArchiveUser archives a user.
func (*SQLQuerier) ArchiveWebhook ¶
func (q *SQLQuerier) ArchiveWebhook(ctx context.Context, webhookID, accountID string) error
ArchiveWebhook archives a webhook from the database.
func (*SQLQuerier) BuildSessionContextDataForUser ¶
func (q *SQLQuerier) BuildSessionContextDataForUser(ctx context.Context, userID string) (*types.SessionContextData, error)
BuildSessionContextDataForUser queries the database for the memberships of a user and constructs a SessionContextData struct from the results.
func (*SQLQuerier) CreateAPIClient ¶
func (q *SQLQuerier) CreateAPIClient(ctx context.Context, input *types.APIClientCreationInput) (*types.APIClient, error)
CreateAPIClient creates an API client.
func (*SQLQuerier) CreateAccount ¶
func (q *SQLQuerier) CreateAccount(ctx context.Context, input *types.AccountCreationInput) (*types.Account, error)
CreateAccount creates an account in the database.
func (*SQLQuerier) CreateItem ¶
func (q *SQLQuerier) CreateItem(ctx context.Context, input *types.ItemDatabaseCreationInput) (*types.Item, error)
CreateItem creates an item in the database.
func (*SQLQuerier) CreateUser ¶
func (q *SQLQuerier) CreateUser(ctx context.Context, input *types.UserDataStoreCreationInput) (*types.User, error)
CreateUser creates a user.
func (*SQLQuerier) CreateWebhook ¶
func (q *SQLQuerier) CreateWebhook(ctx context.Context, input *types.WebhookDatabaseCreationInput) (*types.Webhook, error)
CreateWebhook creates a webhook in a database.
func (*SQLQuerier) GetAPIClientByClientID ¶
func (q *SQLQuerier) GetAPIClientByClientID(ctx context.Context, clientID string) (*types.APIClient, error)
GetAPIClientByClientID gets an API client from the database.
func (*SQLQuerier) GetAPIClientByDatabaseID ¶
func (q *SQLQuerier) GetAPIClientByDatabaseID(ctx context.Context, clientID, userID string) (*types.APIClient, error)
GetAPIClientByDatabaseID gets an API client from the database.
func (*SQLQuerier) GetAPIClients ¶
func (q *SQLQuerier) GetAPIClients(ctx context.Context, userID string, filter *types.QueryFilter) (x *types.APIClientList, err error)
GetAPIClients gets a list of API clients.
func (*SQLQuerier) GetAccount ¶
func (q *SQLQuerier) GetAccount(ctx context.Context, accountID, userID string) (*types.Account, error)
GetAccount fetches an account from the database.
func (*SQLQuerier) GetAccounts ¶
func (q *SQLQuerier) GetAccounts(ctx context.Context, userID string, filter *types.QueryFilter) (x *types.AccountList, err error)
GetAccounts fetches a list of accounts from the database that meet a particular filter.
func (*SQLQuerier) GetAccountsForAdmin ¶
func (q *SQLQuerier) GetAccountsForAdmin(ctx context.Context, filter *types.QueryFilter) (x *types.AccountList, err error)
GetAccountsForAdmin fetches a list of accounts from the database that meet a particular filter for all users.
func (*SQLQuerier) GetAllAccountsCount ¶
func (q *SQLQuerier) GetAllAccountsCount(ctx context.Context) (uint64, error)
GetAllAccountsCount fetches the count of accounts from the database that meet a particular filter.
func (*SQLQuerier) GetAllUsersCount ¶
func (q *SQLQuerier) GetAllUsersCount(ctx context.Context) (uint64, error)
GetAllUsersCount fetches a count of users from the database that meet a particular filter.
func (*SQLQuerier) GetAllWebhooksCount ¶
func (q *SQLQuerier) GetAllWebhooksCount(ctx context.Context) (uint64, error)
GetAllWebhooksCount fetches the count of webhooks from the database that meet a particular filter.
func (*SQLQuerier) GetDefaultAccountIDForUser ¶
GetDefaultAccountIDForUser retrieves the default account ID for a user.
func (*SQLQuerier) GetItems ¶
func (q *SQLQuerier) GetItems(ctx context.Context, accountID string, filter *types.QueryFilter) (x *types.ItemList, err error)
GetItems fetches a list of items from the database that meet a particular filter.
func (*SQLQuerier) GetItemsWithIDs ¶
func (q *SQLQuerier) GetItemsWithIDs(ctx context.Context, accountID string, limit uint8, ids []string) ([]*types.Item, error)
GetItemsWithIDs fetches items from the database within a given set of IDs.
func (*SQLQuerier) GetTotalAPIClientCount ¶
func (q *SQLQuerier) GetTotalAPIClientCount(ctx context.Context) (uint64, error)
GetTotalAPIClientCount gets the count of API clients that match the current filter.
func (*SQLQuerier) GetTotalItemCount ¶
func (q *SQLQuerier) GetTotalItemCount(ctx context.Context) (uint64, error)
GetTotalItemCount fetches the count of items from the database that meet a particular filter.
func (*SQLQuerier) GetUserByUsername ¶
GetUserByUsername fetches a user by their username.
func (*SQLQuerier) GetUserWithUnverifiedTwoFactorSecret ¶
func (q *SQLQuerier) GetUserWithUnverifiedTwoFactorSecret(ctx context.Context, userID string) (*types.User, error)
GetUserWithUnverifiedTwoFactorSecret fetches a user with an unverified 2FA secret.
func (*SQLQuerier) GetUsers ¶
func (q *SQLQuerier) GetUsers(ctx context.Context, filter *types.QueryFilter) (x *types.UserList, err error)
GetUsers fetches a list of users from the database that meet a particular filter.
func (*SQLQuerier) GetWebhook ¶
func (q *SQLQuerier) GetWebhook(ctx context.Context, webhookID, accountID string) (*types.Webhook, error)
GetWebhook fetches a webhook from the database.
func (*SQLQuerier) GetWebhooks ¶
func (q *SQLQuerier) GetWebhooks(ctx context.Context, accountID string, filter *types.QueryFilter) (*types.WebhookList, error)
GetWebhooks fetches a list of webhooks from the database that meet a particular filter.
func (*SQLQuerier) IsReady ¶
func (q *SQLQuerier) IsReady(ctx context.Context, maxAttempts uint8) (ready bool)
IsReady is a simple wrapper around the core querier IsReady call.
func (*SQLQuerier) ItemExists ¶
func (q *SQLQuerier) ItemExists(ctx context.Context, itemID, accountID string) (exists bool, err error)
ItemExists fetches whether an item exists from the database.
func (*SQLQuerier) MarkAccountAsUserDefault ¶
func (q *SQLQuerier) MarkAccountAsUserDefault(ctx context.Context, userID, accountID string) error
MarkAccountAsUserDefault does a thing.
func (*SQLQuerier) MarkUserTwoFactorSecretAsVerified ¶
func (q *SQLQuerier) MarkUserTwoFactorSecretAsVerified(ctx context.Context, userID string) error
MarkUserTwoFactorSecretAsVerified marks a user's two factor secret as validated.
func (*SQLQuerier) Migrate ¶
func (q *SQLQuerier) Migrate(ctx context.Context, maxAttempts uint8, testUserConfig *types.TestUserCreationConfig) error
Migrate is a simple wrapper around the core querier Migrate call.
func (*SQLQuerier) ModifyUserPermissions ¶
func (q *SQLQuerier) ModifyUserPermissions(ctx context.Context, accountID, userID string, input *types.ModifyUserPermissionsInput) error
ModifyUserPermissions does a thing.
func (*SQLQuerier) ProvideSessionStore ¶
func (q *SQLQuerier) ProvideSessionStore() scs.Store
ProvideSessionStore provides the scs Store for MySQL.
func (*SQLQuerier) RemoveUserFromAccount ¶
func (q *SQLQuerier) RemoveUserFromAccount(ctx context.Context, userID, accountID string) error
RemoveUserFromAccount removes a user's membership to an account.
func (*SQLQuerier) SearchForUsersByUsername ¶
func (q *SQLQuerier) SearchForUsersByUsername(ctx context.Context, usernameQuery string) ([]*types.User, error)
SearchForUsersByUsername fetches a list of users whose usernames begin with a given query.
func (*SQLQuerier) TransferAccountOwnership ¶
func (q *SQLQuerier) TransferAccountOwnership(ctx context.Context, accountID string, input *types.AccountOwnershipTransferInput) error
TransferAccountOwnership does a thing.
func (*SQLQuerier) UpdateAccount ¶
UpdateAccount updates a particular account. Note that UpdateAccount expects the provided input to have a valid ID.
func (*SQLQuerier) UpdateItem ¶
UpdateItem updates a particular item. Note that UpdateItem expects the provided input to have a valid ID.
func (*SQLQuerier) UpdateUser ¶
UpdateUser receives a complete Requester struct and updates its record in the database. NOTE: this function uses the ID provided in the input to make its query.
func (*SQLQuerier) UpdateUserPassword ¶
func (q *SQLQuerier) UpdateUserPassword(ctx context.Context, userID, newHash string) error
UpdateUserPassword updates a user's passwords hash in the database.
func (*SQLQuerier) UpdateUserReputation ¶
func (q *SQLQuerier) UpdateUserReputation(ctx context.Context, userID string, input *types.UserReputationUpdateInput) error
UpdateUserReputation updates a user's account status.
func (*SQLQuerier) UpdateUserTwoFactorSecret ¶
func (q *SQLQuerier) UpdateUserTwoFactorSecret(ctx context.Context, userID, newSecret string) error
UpdateUserTwoFactorSecret marks a user's two factor secret as validated.
func (*SQLQuerier) UserHasStatus ¶
func (q *SQLQuerier) UserHasStatus(ctx context.Context, userID string, statuses ...string) (banned bool, err error)
UserHasStatus fetches whether an user has a particular status.
func (*SQLQuerier) UserIsMemberOfAccount ¶
func (q *SQLQuerier) UserIsMemberOfAccount(ctx context.Context, userID, accountID string) (bool, error)
UserIsMemberOfAccount does a thing.
func (*SQLQuerier) WebhookExists ¶
func (q *SQLQuerier) WebhookExists(ctx context.Context, webhookID, accountID string) (exists bool, err error)
WebhookExists fetches whether a webhook exists from the database.