datastore

package
v0.0.0-...-6fbf478 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(plainPwd string) (string, error)

Types

type Books

type Books interface {
	AddBook(ctx context.Context, book *model.Book) error
	ListBooks(ctx context.Context) ([]model.Book, error)
	SearchBooks(ctx context.Context, tag string) ([]model.Book, error)
	GetBook(ctx context.Context, id string) (model.Book, error)
	UpdateBook(ctx context.Context, id string, book model.Book) (int, error)
	DeleteBook(ctx context.Context, id string) (int, error)
}

type BooksClient

type BooksClient struct {
	// contains filtered or unexported fields
}

BooksClient is the client responsible for querying mongodb

func NewBooksClient

func NewBooksClient(client *mongo.Client, cfg *viper.Viper) *BooksClient

func (*BooksClient) AddBook

func (c *BooksClient) AddBook(ctx context.Context, book *model.Book) error

AddBook wrapper to add a book to the MongoDB collection

func (*BooksClient) DeleteBook

func (c *BooksClient) DeleteBook(ctx context.Context, id string) (int, error)

DeleteBook wrapper to delete a book from the MongoDB collection

func (*BooksClient) GetBook

func (c *BooksClient) GetBook(ctx context.Context, id string) (model.Book, error)

func (*BooksClient) InitBooks

func (c *BooksClient) InitBooks(ctx context.Context)

func (*BooksClient) ListBooks

func (c *BooksClient) ListBooks(ctx context.Context) ([]model.Book, error)

ListBooks wrapper to return all books from the MongoDB collection

func (*BooksClient) SearchBooks

func (c *BooksClient) SearchBooks(ctx context.Context, tag string) ([]model.Book, error)

SearchBooks wrapper to return all books based on a 'tag' from the MongoDB collection

func (*BooksClient) UpdateBook

func (c *BooksClient) UpdateBook(ctx context.Context, id string, book model.Book) (int, error)

type CookieStoreClient

type CookieStoreClient struct {
	Config *viper.Viper
}

CookieStoreClient is the client responsible for managing cookies

func (CookieStoreClient) NewCookieStore

func (c CookieStoreClient) NewCookieStore() (redisStore.Store, error)

type Redis

type Redis interface {
	GetBooks(ctx context.Context) ([]model.Book, error)
	SetBooks(ctx context.Context, books []model.Book) error
	GetBook(ctx context.Context, id string) (model.Book, error)
	SetBook(ctx context.Context, id string, book model.Book) error
	DeleteEntry(ctx context.Context, id string)
}

type RedisClient

type RedisClient struct {
	// contains filtered or unexported fields
}

RedisClient is the client responsible for querying redis

func NewRedisClient

func NewRedisClient(client *redis.Client, cfg *viper.Viper) *RedisClient

func (*RedisClient) DeleteEntry

func (c *RedisClient) DeleteEntry(ctx context.Context, id string)

DeleteEntry wrapper to delete a book entry from Redis

func (*RedisClient) GetBook

func (c *RedisClient) GetBook(ctx context.Context, id string) (model.Book, error)

GetBook wrapper to return a cached book from Redis

func (*RedisClient) GetBooks

func (c *RedisClient) GetBooks(ctx context.Context) ([]model.Book, error)

GetBooks wrapper to return all books from Redis

func (*RedisClient) SetBook

func (c *RedisClient) SetBook(ctx context.Context, id string, book model.Book) error

SetBook wrapper to set a book on Redis

func (*RedisClient) SetBooks

func (c *RedisClient) SetBooks(ctx context.Context, books []model.Book) error

SetBooks wrapper to set the current list of Books on Redis

type Users

type Users interface {
	Get(ctx context.Context, username string, password string) (model.User, error)
}

type UsersClient

type UsersClient struct {
	// contains filtered or unexported fields
}

BooksClient is the client responsible for querying mongodb

func NewUsersClient

func NewUsersClient(client *mongo.Client, cfg *viper.Viper) *UsersClient

NewUsersClient create a new UsersClient

func (*UsersClient) Get

func (c *UsersClient) Get(ctx context.Context, username string, password string) (model.User, error)

Get returns a user by username

func (*UsersClient) InitUsers

func (c *UsersClient) InitUsers(ctx context.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL