Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDuplicateContact is returned when more than one contacts // were found, while at most one was expected. ErrDuplicateContact = fmt.Errorf("Duplicate contact") // ErrContactNotFound is returned in case a contact was not found. ErrContactNotFound = fmt.Errorf("Contact not found") // ErrContactAlreadyExists is returned in case the contact // already exists when attempting to insert it. ErrContactAlreadyExists = fmt.Errorf("Contact already exists") )
View Source
var ( // ErrDuplicateDiscussion is returned when more then one discussions // were found, while at most one was expected. ErrDuplicateDiscussion = fmt.Errorf("Duplicate discussion") // ErrDiscussionNotFound is returned in case a discussion was not found. ErrDiscussionNotFound = fmt.Errorf("Discussion not found") // ErrDiscussionAlreadyExists is returned in case the discussion // already exists when attempting to insert it. ErrDiscussionAlreadyExists = fmt.Errorf("Discussion already exists") // ErrMessageNotFound is returned in case a message id was not found. ErrMessageNotFound = fmt.Errorf("Message not found") // ErrMessageInvalidDisc is returned in case a message does // not belong to a discussion. ErrMessageInvalidDisc = fmt.Errorf("Message does not belong to discussion") )
View Source
var ( // ErrMaxRetries is returned in case a query conflict // could not be resolved after the maximum number of retries. ErrMaxRetries = fmt.Errorf("could not resolve transaction conflict after max retries") )
Functions ¶
func WithBadgerOption ¶
func WithBadgerOption(f func(badger.Options) badger.Options) func(Database)
WithBadgerOption sets a badger option. Useful for passing badger options to badgerhold.
func WithLogger ¶
WithLogger sets the database logger.
Types ¶
type AlreadyExistsError ¶
type AlreadyExistsError struct {
// contains filtered or unexported fields
}
func (*AlreadyExistsError) Error ¶
func (e *AlreadyExistsError) Error() string
func (*AlreadyExistsError) Value ¶
func (e *AlreadyExistsError) Value() interface{}
type Database ¶
type Database interface { // Contacts AddContact(c *model.Contact) (contact *model.Contact, err error) GetContact(address string) (*model.Contact, error) GetContactByID(uid uint64) (*model.Contact, error) RemoveContact(address string) (*model.Contact, error) RemoveContactByID(uid uint64) (*model.Contact, error) GetContacts() ([]model.Contact, error) // Discussions AddDiscussion(disc *model.Discussion) (discussion *model.Discussion, err error) GetDiscussion(uid uint64) (*model.Discussion, error) GetDiscussionByParticipants(participants []string) (*model.Discussion, error) RemoveDiscussion(uid uint64) (*model.Discussion, error) GetDiscussions(seekIndex, pageSize uint64) ([]model.Discussion, error) UpdateDiscussionLastRead(uid uint64, readMsgID uint64) error // Invoices-Payments AddInvoice(inv *model.Invoice) error AddPayments(payments ...*model.Payment) error GetLastInvoiceIndex() (invSettleIndex uint64, err error) GetLastPaymentIndex() (paymentIndex uint64, err error) GetInvoices(pageOpts model.PageOptions) ([]*model.Invoice, error) GetPayments(pageOpts model.PageOptions) ([]*model.Payment, error) AddRawMessage(*model.RawMessage) error GetMessages(discussionUID uint64, pageOpts model.PageOptions) ([]model.MessageAggregate, error) // Close closes the database Close() error }
Database provices the generic interface for database operations.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.