Documentation ¶
Index ¶
Constants ¶
View Source
const (
// TypePostgres holder for postgres database
TypePostgres = "POSTGRES"
)
Variables ¶
This section is empty.
Functions ¶
func NewErrAlreadyExists ¶
NewErrAlreadyExists wraps a message in an ErrAlreadyExists object.
Types ¶
type DB ¶
type DB interface { // Close closes the db connections Close(ctx context.Context) Error // DoMigration runs database migrations DoMigration(ctx context.Context) Error TxNew(ctx context.Context) (TxID, Error) TxCommit(ctx context.Context, id TxID) Error TxRollback(ctx context.Context, id TxID) Error // CountAccounts returns the number of federated social account CountAccounts(ctx context.Context) (count int64, err Error) // CountAccountsForInstance returns the number of federated social account for an instance CountAccountsForInstance(ctx context.Context, instanceID int64) (count int64, err Error) // CreateAccount stores the federated social account CreateAccount(ctx context.Context, account *models.Account) (err Error) // IncAccountLoginCount updates the login count of a stored federated instance IncAccountLoginCount(ctx context.Context, account *models.Account) (err Error) // ReadAccount returns one federated social account ReadAccount(ctx context.Context, id int64) (account *models.Account, err Error) // ReadAccountByUsername returns one federated social account ReadAccountByUsername(ctx context.Context, instanceID int64, username string) (account *models.Account, err Error) // ReadAccountsPage returns a page of federated social accounts ReadAccountsPage(ctx context.Context, index, count int) (instances []*models.Account, err Error) // UpdateAccount updates the stored federated instance UpdateAccount(ctx context.Context, account *models.Account) (err Error) // CountBlocks returns the number of domain blocks CountBlocks(ctx context.Context) (count int64, err Error) // CreateBlockTX stores the domain block in a transaction. CreateBlockTX(ctx context.Context, txID TxID, blocks ...*models.Block) (err Error) // DeleteBlock deletes a domain block. DeleteBlock(ctx context.Context, blocks ...*models.Block) (err Error) // ReadBlock returns one domain block ReadBlock(ctx context.Context, id int64) (block *models.Block, err Error) // ReadBlockByDomain returns one domain block by domain name ReadBlockByDomain(ctx context.Context, domain string) (block *models.Block, err Error) // ReadBlocks returns all domain blocks ReadBlocks(ctx context.Context) (blocks []*models.Block, err Error) // ReadBlocksPage returns a page of domain blocks ReadBlocksPage(ctx context.Context, index, count int) (blocks []*models.Block, err Error) // UpdateBlockTX updates the stored domain block in a transaction UpdateBlockTX(ctx context.Context, txID TxID, blocks ...*models.Block) (err Error) // CreateConfigTX stores the configs using a transaction. CreateConfigTX(ctx context.Context, txID TxID, configs ...*models.Config) (err Error) // DeleteConfigTX deletes configs using a transaction. DeleteConfigTX(ctx context.Context, txID TxID, configs ...*models.Config) (err Error) // ReadConfig returns one config. ReadConfig(ctx context.Context, id int64) (config *models.Config, err Error) // ReadConfigByKey returns one config. ReadConfigByKey(ctx context.Context, key models.ConfigKey) (config *models.Config, err Error) // ReadConfigsForAccountForKeys returns configs for matching keys. ReadConfigsForAccountForKeys(ctx context.Context, accountID int64, keys ...models.ConfigKey) (configs []*models.Config, err Error) // ReadConfigsForKeysSystem returns configs for matching keys. ReadConfigsForKeysSystem(ctx context.Context, keys ...models.ConfigKey) (configs []*models.Config, err Error) // ReadConfigsForKeysUser returns configs for matching keys. ReadConfigsForKeysUser(ctx context.Context, keys ...models.ConfigKey) (configs []*models.Config, err Error) // UpdateConfigTX updates configs using a transaction. UpdateConfigTX(ctx context.Context, txID TxID, configs ...*models.Config) (err Error) // CountInstances returns the number of federated instance CountInstances(ctx context.Context) (count int64, err Error) // CreateInstance stores the federated instance CreateInstance(ctx context.Context, instance *models.Instance) (err Error) // ReadInstance returns one federated social instance ReadInstance(ctx context.Context, id int64) (instance *models.Instance, err Error) // ReadInstanceByActorIRI returns one federated social instance ReadInstanceByActorIRI(ctx context.Context, actorIRI string) (instance *models.Instance, err Error) // ReadInstanceByDomain returns one federated social instance ReadInstanceByDomain(ctx context.Context, domain string) (instance *models.Instance, err Error) // ReadInstanceByServerHostname returns one federated social instance ReadInstanceByServerHostname(ctx context.Context, serverHostname string) (instance *models.Instance, err Error) // ReadInstances returns a set of requested of federated social instances ReadInstances(ctx context.Context, ids ...int64) (instances []*models.Instance, err Error) // ReadInstancesPage returns a page of federated social instances ReadInstancesPage(ctx context.Context, index, count int) (instances []*models.Instance, err Error) // ReadInstancesWithBlockID returns all instances with block id ReadInstancesWithBlockID(ctx context.Context, blockID int64) (instances []*models.Instance, err Error) // ReadInstancesWithDomainSuffix returns all instances with domain suffix ReadInstancesWithDomainSuffix(ctx context.Context, domainSuffix string) (instances []*models.Instance, err Error) // ReadInstancesWhereFollowing returns all federated social instances which are following this relay ReadInstancesWhereFollowing(ctx context.Context) (instances []*models.Instance, err Error) // UpdateInstance updates the stored federated instance UpdateInstance(ctx context.Context, instance *models.Instance) (err Error) // UpdateInstanceTX updates the stored federated instance in a transaction. UpdateInstanceTX(ctx context.Context, txID TxID, instance *models.Instance) (err Error) // CountLogEntries returns the number of log entries. CountLogEntries(ctx context.Context) (count int64, err Error) // CreateLogEntryTX stores the log entries in a transaction. CreateLogEntryTX(ctx context.Context, txID TxID, logEntries ...*models.LogEntry) (err Error) // ReadLogEntriesPage returns a page of log entries. ReadLogEntriesPage(ctx context.Context, index, count int, asc bool) (instances []*models.LogEntry, err Error) }
DB represents a database client
type ErrAlreadyExists ¶
type ErrAlreadyExists struct {
// contains filtered or unexported fields
}
ErrAlreadyExists is returned when a caller tries to insert a database entry that already exists in the db.
func (*ErrAlreadyExists) Error ¶
func (e *ErrAlreadyExists) Error() string
Error returns the error message as a string.
type Error ¶
type Error error
Error represents a database specific error
var ( // ErrGenID is returned when creating a new ID can't be generated for a new model. ErrGenID Error = fmt.Errorf("can't generate id") // ErrNoEntries is returned when a caller expected an entry for a query, but none was found. ErrNoEntries Error = fmt.Errorf("no entries") // ErrMultipleEntries is returned when a caller expected ONE entry for a query, but multiples were found. ErrMultipleEntries Error = fmt.Errorf("multiple entries") // ErrUnknown denotes an unknown database error. ErrUnknown Error = fmt.Errorf("unknown error") )
Click to show internal directories.
Click to hide internal directories.