Documentation
¶
Index ¶
- Constants
- type InMemoryStapleStorer
- func (p InMemoryStapleStorer) Archive(email string, stapleID int) error
- func (p InMemoryStapleStorer) Create(staple models.Staple, email string) error
- func (p InMemoryStapleStorer) Delete(email string, stapleID int) error
- func (p InMemoryStapleStorer) Get(email string, stapleID int) (*models.Staple, error)
- func (p InMemoryStapleStorer) List(email string) ([]models.Staple, error)
- func (p InMemoryStapleStorer) Oldest(email string) (*models.Staple, error)
- func (p InMemoryStapleStorer) ShowArchive(email string) ([]models.Staple, error)
- type InMemoryUserStorer
- type PostgresStapleStorer
- func (p PostgresStapleStorer) Archive(email string, stapleID int) error
- func (p PostgresStapleStorer) Create(staple models.Staple, email string) error
- func (p PostgresStapleStorer) Delete(email string, stapleID int) error
- func (p PostgresStapleStorer) Get(email string, stapleID int) (*models.Staple, error)
- func (p PostgresStapleStorer) List(email string) ([]models.Staple, error)
- func (p PostgresStapleStorer) Oldest(email string) (*models.Staple, error)
- func (p PostgresStapleStorer) ShowArchive(email string) ([]models.Staple, error)
- type PostgresUserStorer
- type StapleStorer
- type UserStorer
Constants ¶
const (
// DefaultMaxStaples is 25.
DefaultMaxStaples = 25
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InMemoryStapleStorer ¶
type InMemoryStapleStorer struct {
Err error // can be set to simulate an error
// contains filtered or unexported fields
}
InMemoryStapleStorer is a storer which uses a map as a storage backend.
func NewInMemoryStapleStorer ¶
func NewInMemoryStapleStorer() InMemoryStapleStorer
NewInMemoryStapleStorer creates a new in memory storage medium.
func (InMemoryStapleStorer) Archive ¶
func (p InMemoryStapleStorer) Archive(email string, stapleID int) error
Archive archives a staple.
func (InMemoryStapleStorer) Create ¶
func (p InMemoryStapleStorer) Create(staple models.Staple, email string) error
Create will create a staple in the underlying in memory storage medium.
func (InMemoryStapleStorer) Delete ¶
func (p InMemoryStapleStorer) Delete(email string, stapleID int) error
Delete removes a staple.
func (InMemoryStapleStorer) List ¶
func (p InMemoryStapleStorer) List(email string) ([]models.Staple, error)
List gets all the not archived staples for a user. List will not retrieve the content since that can possibly be a large text. We only ever retrieve it when that specific staple is Get.
func (InMemoryStapleStorer) Oldest ¶
func (p InMemoryStapleStorer) Oldest(email string) (*models.Staple, error)
Oldest will get the oldest staple that is not archived.
func (InMemoryStapleStorer) ShowArchive ¶
func (p InMemoryStapleStorer) ShowArchive(email string) ([]models.Staple, error)
ShowArchive will return the users archived staples ordered by id.
type InMemoryUserStorer ¶
type InMemoryUserStorer struct {
Err error
// contains filtered or unexported fields
}
InMemoryUserStorer is a storer which uses memory as a storage backend.
func NewInMemoryUserStorer ¶
func NewInMemoryUserStorer() InMemoryUserStorer
NewInMemoryUserStorer creates a new in memory storage medium.
func (InMemoryUserStorer) Create ¶
func (s InMemoryUserStorer) Create(email string, password []byte) error
Create saves a user in in memory.
func (InMemoryUserStorer) Delete ¶
func (s InMemoryUserStorer) Delete(email string) error
Delete deletes a user from in memory.
type PostgresStapleStorer ¶
type PostgresStapleStorer struct{}
PostgresStapleStorer is a storer which uses Postgres as a storage backend.
func NewPostgresStapleStorer ¶
func NewPostgresStapleStorer() PostgresStapleStorer
NewPostgresStapleStorer creates a new Postgres storage medium.
func (PostgresStapleStorer) Archive ¶
func (p PostgresStapleStorer) Archive(email string, stapleID int) error
Archive archives a staple.
func (PostgresStapleStorer) Create ¶
func (p PostgresStapleStorer) Create(staple models.Staple, email string) error
Create will create a staple in the underlying postgres storage medium.
func (PostgresStapleStorer) Delete ¶
func (p PostgresStapleStorer) Delete(email string, stapleID int) error
Delete removes a staple.
func (PostgresStapleStorer) List ¶
func (p PostgresStapleStorer) List(email string) ([]models.Staple, error)
List gets all the not archived staples for a user. List will not retrieve the content since that can possibly be a large text. We only ever retrieve it when that specific staple is Get.
func (PostgresStapleStorer) Oldest ¶
func (p PostgresStapleStorer) Oldest(email string) (*models.Staple, error)
Oldest will get the oldest staple that is not archived.
func (PostgresStapleStorer) ShowArchive ¶
func (p PostgresStapleStorer) ShowArchive(email string) ([]models.Staple, error)
ShowArchive will return the users archived staples ordered by id.
type PostgresUserStorer ¶
type PostgresUserStorer struct{}
PostgresUserStorer is a storer which uses Postgres as a storage backend.
func NewPostgresUserStorer ¶
func NewPostgresUserStorer() PostgresUserStorer
NewPostgresUserStorer creates a new Postgres storage medium.
func (PostgresUserStorer) Create ¶
func (s PostgresUserStorer) Create(email string, password []byte) error
Create saves a user in the db.
func (PostgresUserStorer) Delete ¶
func (s PostgresUserStorer) Delete(email string) error
Delete deletes a user from the db.
type StapleStorer ¶
type StapleStorer interface {
Create(staple models.Staple, email string) error
Delete(email string, stapleID int) error
Get(email string, stapleID int) (*models.Staple, error)
List(email string) ([]models.Staple, error)
Archive(email string, stapleID int) error
Oldest(email string) (*models.Staple, error)
ShowArchive(email string) ([]models.Staple, error)
}
StapleStorer defines a set of functions for storing staples.