dao

package
v0.0.0-...-57f2031 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	UserDAO        *UserDAO
	PlanDAO        *PlanDAO
	PlanSessionDAO *PlanSessionDAO
	// contains filtered or unexported fields
}

Conn handle db connection and DAO instanciation.

func Open

func Open(conf *configuration.GlobalConf) (conn *Conn)

Open init connection to database and init all prepared statement. If something wrong happened, it panics.

type DbError

type DbError struct {
	Message string
	Type    DbErrorType
}

DbError allow to give more context when an error happend in DAO layer

type DbErrorType

type DbErrorType string
const (
	CONFLICT  DbErrorType = "conflict"
	UNKNOWN   DbErrorType = "unknown"
	NOT_FOUND DbErrorType = "not_found"
)

type PlanDAO

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

PlanDAO allow accessing plan table

func (*PlanDAO) Exists

func (p *PlanDAO) Exists(ctx context.Context, id string) (bool, *DbError)

func (*PlanDAO) Insert

func (p *PlanDAO) Insert(ctx context.Context, plan *model.Plan) (*model.Plan, *DbError)

Insert a new plan

type PlanSessionDAO

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

PlanDAO allow accessing plan table

func (*PlanSessionDAO) Insert

func (p *PlanSessionDAO) Insert(ctx context.Context, planSession *model.PlanSession) (*model.PlanSession, *DbError)

Insert a new plan

func (*PlanSessionDAO) List

func (p *PlanSessionDAO) List(ctx context.Context, planId string, from time.Time, to time.Time) ([]*model.PlanSession, *DbError)

type UserDAO

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

UserDAO allow accessing user table

func (*UserDAO) CheckPassword

func (u *UserDAO) CheckPassword(ctx context.Context, user *model.User) (*model.User, *DbError)

CheckPassword is used for login / password autentication

func (*UserDAO) GetUser

func (u *UserDAO) GetUser(ctx context.Context, id string) (*model.User, *DbError)

CheckPassword is used for login / password autentication

func (*UserDAO) Insert

func (u *UserDAO) Insert(ctx context.Context, user *model.User) (*model.User, *DbError)

Insert a new user

Jump to

Keyboard shortcuts

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