word

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

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

Go to latest
Published: Mar 27, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDublicateWord = errors.New("Repository has found the same word")

ErrDublicateWord erorr when word is not found

View Source
var ErrRepository = errors.New("Repository cannot do that you want")

ErrRepository is the default erorr in repo

View Source
var ErrWordNotFound = errors.New("Repository cannot has found one")

ErrWordNotFound erorr when word is not found

Functions

This section is empty.

Types

type BadgerRepository

type BadgerRepository struct {
	sync.Mutex
	// contains filtered or unexported fields
}

BadgerRepository is implementation Repository by Badger

func (*BadgerRepository) AddWordInto

func (br *BadgerRepository) AddWordInto(ctx context.Context, word Word) error

AddWordInto adds word into badger if this one doesn't exiest there

func (*BadgerRepository) GetWordByID

func (br *BadgerRepository) GetWordByID(ctx context.Context, id string) (Word, error)

GetWordByID gets word from badger by ID

func (*BadgerRepository) GetWordByW

func (br *BadgerRepository) GetWordByW(ctx context.Context, word string) (Word, error)

GetWordByW gets word from badger by W

func (*BadgerRepository) Words

func (br *BadgerRepository) Words(ctx context.Context) ([]Word, error)

Words todo: refactor

type Repository

type Repository interface {
	Words(ctx context.Context) ([]Word, error)
	AddWordInto(ctx context.Context, word Word) error
	GetWordByID(ctx context.Context, id string) (Word, error)
	GetWordByW(ctx context.Context, w string) (Word, error)
}

func NewBadgerRepository

func NewBadgerRepository(dir string, logger log.Logger) Repository

NewBadgerRepository creates and returns new repository

type Word

type Word struct {
	ID            string   `json:"id,omitempty"`
	W             string   `json:"text"`
	Transcription string   `json:"transcription"`
	Examples      []string `json:"examples,omitempty"`
	Timestamp     int64    `json:"timestamp,omitempty"`
}

Word represents a word

Jump to

Keyboard shortcuts

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