Documentation ¶
Overview ¶
Package sqlite provides implementation of api.PasteService that uses sqlite database as a storage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PasteService ¶
type PasteService struct { Options SvcOptions // contains filtered or unexported fields }
PasteService stores all the pastes in sqlite database and implements the api.PasteService interface.
func New ¶
func New(opts SvcOptions) (*PasteService, error)
New returns new PasteService with an empty map of pastes.
func (*PasteService) Create ¶
Create initialises a new paste from the provided data and adds it to the storage. It returns the newly created paste.
func (*PasteService) Delete ¶
func (s *PasteService) Delete(id int64) error
Delete removes the paste from the storage
func (*PasteService) Get ¶
func (s *PasteService) Get(id int64) (*api.Paste, error)
Get returns a paste by it's ID. The return values are as follows: - if there is a problem talking to the database paste== nil, err != nil - if paste is not found paste== nil, err == nil - if paste is found paste != nil, err == nil
type SvcOptions ¶
type SvcOptions struct { // Database connection string. // For sqlite it should be either a file name or `file::memory:?cache=shared` // to use temporary database in memory (ex. for testing). DBConnection *gorm.DB // DBAutoMigrate bool }
SvcOptions contains all the options needed to create an instance of PasteService