postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package postgres provides a postgresql implementation of the repository.Repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// DBName is the name of the database to use.
	//
	// It must exist.
	//
	// It is required.
	DBName string

	// Host is the host of the database.
	//
	// It is required.
	Host string

	// User is the username to use.
	//
	// It is required.
	User string
	// Password is the password to use.
	//
	// It is required.
	Password string

	// Logger is the logger used to log sql queries.
	Logger *zap.SugaredLogger
}

Options contains the options used to configure the repository.

type Repository

type Repository struct {
	DB *gorm.DB
}

func Open

func Open(o Options) (*Repository, error)

func (*Repository) CreateWord

func (r *Repository) CreateWord(ctx context.Context, w repository.Word) (repository.WordID, error)

func (*Repository) DeleteWord

func (r *Repository) DeleteWord(ctx context.Context, id repository.WordID) error

func (*Repository) SearchTranslation

func (r *Repository) SearchTranslation(ctx context.Context, query string) ([]repository.TranslatedWord, error)

func (*Repository) SearchWord

func (r *Repository) SearchWord(ctx context.Context, query string) (*repository.Word, error)

func (*Repository) Word

func (*Repository) WordRoot

func (r *Repository) WordRoot(ctx context.Context, root string) (*repository.WordRoot, error)

Jump to

Keyboard shortcuts

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