datastore

package
v0.0.0-...-459856e Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBORM

type DBORM struct {
	*gorm.DB
}

DBORM is an ORM layer that satisfies the DBLayer interface

func NewORM

func NewORM(dbname, con string) (*DBORM, error)

NewORM is a constructor for DBORM

type EventRepo

type EventRepo interface {
	GetAllEvents() ([]models.Event, error)
	GetEventByID(id int) (models.Event, error)
	AddEvent(models.Event) (models.Event, error)
	UpdateEvent(models.Event) error
	DeleteEvent(*models.Event) error
}

EventRepo is the abstraction for event related database operations

func NewEventRepo

func NewEventRepo(orm *DBORM) (EventRepo, error)

NewEventRepo is a constructor for DBORM

type EventStore

type EventStore struct {
	DBORM
}

EventStore is an ORM layer that satisfies the DBLayer interface

func (*EventStore) AddEvent

func (store *EventStore) AddEvent(event models.Event) (models.Event, error)

AddEvent adds an event and returns it

func (*EventStore) DeleteEvent

func (store *EventStore) DeleteEvent(event *models.Event) error

DeleteEvent deletes an event object and returns it

func (*EventStore) GetAllEvents

func (store *EventStore) GetAllEvents() (events []models.Event, err error)

GetAllEvents returns all events

func (*EventStore) GetEventByID

func (store *EventStore) GetEventByID(id int) (event models.Event, err error)

GetEventByID returns an event or an error

func (*EventStore) UpdateEvent

func (store *EventStore) UpdateEvent(event models.Event) error

UpdateEvent updates an Event object

type UserRepo

type UserRepo interface {
	GetAllUsers() ([]models.User, error)
	GetUserByAlias(alias string) (models.User, error)
	GetUserByID(id int) (models.User, error)
	AddUser(models.User) (models.User, error)
	UpdateUser(*models.User) error
	DeleteUser(models.User) error
}

UserRepo is the abstraction for user related database operations

func NewUserRepo

func NewUserRepo(orm *DBORM) (UserRepo, error)

NewUserRepo is a constructor

type UserStore

type UserStore struct {
	DBORM
}

UserStore is an ORM layer that satisfies the UserRepo interface

func (*UserStore) AddUser

func (store *UserStore) AddUser(newUser models.User) (models.User, error)

AddUser adds a User object to the database and returns the user

func (*UserStore) DeleteUser

func (store *UserStore) DeleteUser(user models.User) error

DeleteUser deletes a User object and returns the object with DeletedAt timestamp

func (*UserStore) GetAllUsers

func (store *UserStore) GetAllUsers() (users []models.User, err error)

GetAllUsers returns a list of User objects

func (*UserStore) GetUserByAlias

func (store *UserStore) GetUserByAlias(alias string) (user models.User, err error)

GetUserByAlias returns the User object of the user with the given alias

func (*UserStore) GetUserByID

func (store *UserStore) GetUserByID(id int) (user models.User, err error)

GetUserByID returns the User object of the user with the given ID

func (*UserStore) UpdateUser

func (store *UserStore) UpdateUser(user *models.User) error

UpdateUser updates a User object and returns it

Jump to

Keyboard shortcuts

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