gorm

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepository

func NewRepository(db *gorm.DB) *repository.Repository

NewRepository returns a Repository which uses gorm.DB for querying the database

func NewSessionRepository

func NewSessionRepository(db *gorm.DB) repository.SessionRepository

NewSessionRepository returns pointer to repo along with the db

func NewUserRepository

func NewUserRepository(db *gorm.DB) repository.UserRepository

NewUserRepository returns a DefaultUserRepository which uses gorm.DB for querying the database

Types

type SessionRepository

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

SessionRepository uses gorm.DB for querying the database

func (*SessionRepository) CreateSession

func (s *SessionRepository) CreateSession(session *models.Session) (*models.Session, error)

CreateSession must take in Key, Data, and ExpiresAt as arguments.

func (*SessionRepository) DeleteSession

func (s *SessionRepository) DeleteSession(session *models.Session) (*models.Session, error)

DeleteSession deletes a session by Key

func (*SessionRepository) SelectSession

func (s *SessionRepository) SelectSession(session *models.Session) (*models.Session, error)

SelectSession returns a session with matching key

func (*SessionRepository) UpdateSession

func (s *SessionRepository) UpdateSession(session *models.Session) (*models.Session, error)

UpdateSession updates only the Data field using Key as selector.

type UserRepository

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

UserRepository uses gorm.DB for querying the database

func (*UserRepository) CheckPassword

func (repo *UserRepository) CheckPassword(id int, pwd string) (bool, error)

CheckPassword checks the input password is correct for the provided user id.

func (*UserRepository) CreateUser

func (repo *UserRepository) CreateUser(user *models.User) (*models.User, error)

CreateUser adds a new User row to the Users table in the database

func (*UserRepository) DeleteUser

func (repo *UserRepository) DeleteUser(user *models.User) (*models.User, error)

DeleteUser deletes a single user using their unique id

func (*UserRepository) ReadUser

func (repo *UserRepository) ReadUser(id uint) (*models.User, error)

ReadUser finds a single user based on their unique id

func (*UserRepository) ReadUserByEmail

func (repo *UserRepository) ReadUserByEmail(email string) (*models.User, error)

ReadUserByEmail finds a single user based on their unique email

func (*UserRepository) UpdateUser

func (repo *UserRepository) UpdateUser(user *models.User) (*models.User, error)

UpdateUser modifies an existing User in the database

Jump to

Keyboard shortcuts

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