dbs

package
v0.0.0-...-752c475 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = fmt.Errorf("Not found")
	ErrDuplicateKey = fmt.Errorf("Duplicate key")
)
View Source
var People = map[string]*models.Person{
	"1": {ID: "1", Name: "Marco Rosner", Nickname: "Rosner", Birth: "2000-10-01"},
	"2": {ID: "2", Name: "João Rosner", Nickname: "João", Birth: "2000-10-02"},
	"3": {ID: "3", Name: "Maria", Nickname: "Maria", Birth: "2000-10-03"},
}

Functions

func NewPostgresDB

func NewPostgresDB() *postgresDB

Types

type DB

type DB interface {
	Create(*models.Person) error
	Get(string) (*models.Person, error)
	Count() (int, error)
	Search(string) ([]*models.Person, error)
}

type InMemDB

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

func NewInMemDB

func NewInMemDB() *InMemDB

func (*InMemDB) Count

func (db *InMemDB) Count() (int, error)

func (*InMemDB) Create

func (db *InMemDB) Create(p *models.Person) error

func (*InMemDB) Get

func (db *InMemDB) Get(id string) (*models.Person, error)

func (*InMemDB) Search

func (db *InMemDB) Search(term string) ([]*models.Person, error)

type MongoDB

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

func NewMongoDB

func NewMongoDB() *MongoDB

func (*MongoDB) Count

func (db *MongoDB) Count() (int, error)

func (*MongoDB) Create

func (db *MongoDB) Create(p *models.Person) error

func (*MongoDB) Get

func (db *MongoDB) Get(id string) (*models.Person, error)

func (*MongoDB) Search

func (db *MongoDB) Search(term string) ([]*models.Person, error)

Jump to

Keyboard shortcuts

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