Documentation ¶
Index ¶
- type Config
- type Db
- func (db *Db) ClearMessages() error
- func (db *Db) Close()
- func (db *Db) CreateMessage(detailedMessage *model.DetailedMessage) error
- func (db *Db) DeleteMessage(id uint64) error
- func (db *Db) GetMessage(id uint64) (*model.DetailedMessage, error)
- func (db *Db) Initialize() error
- func (db *Db) ListMessages(limit uint64, id uint64) ([]*model.DetailedMessage, uint64, error)
- func (db *Db) UpdateMessage(detailedMessage *model.DetailedMessage) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Db ¶
type Db struct { Config // contains filtered or unexported fields }
Structure to abtract away the underlying database implementation. This is the main handle into the database.
func (*Db) ClearMessages ¶
Delete all Messages from the database. Fast way of doing so is to just delete and re create the bucket.
This function isn't called in the core application. It's created to be called by the unit testing code.
func (*Db) Close ¶
func (db *Db) Close()
Closes the Db. Not strictly necessary in this application, but good practice regardless
func (*Db) CreateMessage ¶
func (db *Db) CreateMessage(detailedMessage *model.DetailedMessage) error
Inserts a new DetailedMessage in the database using "detailedMessage" at the index specified in the message. Returns an error if something went wrong during the transaction.
func (*Db) DeleteMessage ¶
Deletes a DetailedMessage from the database at index "id". Returns an error if something went wrong during the transaction.
func (*Db) GetMessage ¶
func (db *Db) GetMessage(id uint64) (*model.DetailedMessage, error)
Retrieves a DetailedMessage from the database at index "id". Returns an error if something went wrong during the transaction.
func (*Db) ListMessages ¶
Returns a list of up to "limit" number of DetailedMessage starting with the first entry from index "id". A non-0 "afterId" returned indicates that there are more messages left to retrieve from the database.
func (*Db) UpdateMessage ¶
func (db *Db) UpdateMessage(detailedMessage *model.DetailedMessage) error
Replaces a DetailedMessage in the database with "detailedMessage" at the index specified in the message. Returns an error if something went wrong during the transaction.