repository

package
v0.0.0-...-4bcbab6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyExists : Error if the entry does already exist
	ErrAlreadyExists = errors.New("already exists")
	// ErrNilID : Error when id is nil
	ErrNilID = errors.New("nil id")
	// ErrNotFound : Error when entry not found
	ErrNotFound = errors.New("not found")
	// ErrForbidden : Error when access is forbidden
	ErrForbidden = errors.New("forbidden")
)

Functions

This section is empty.

Types

type ArgumentError

type ArgumentError struct {
	FieldName string
	Message   string
}

func (*ArgumentError) Error

func (ae *ArgumentError) Error() string

type DeviceRepository

type DeviceRepository interface {
	CreateDevice(*models.Device) (*models.Device, error)
	// UpdateDevice(*models.Device) (*models.Device, error)
	GetDevice(id uint) (*models.Device, error)
	GetDevices() ([]*models.Device, error)
	GetDevicesByUserID(uint) ([]*models.Device, error)
	DeleteDevice(deviceID uint) error
}

DeviceRepository : Device repository to predfine the interfaces

type GormRepository

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

GormRepository : Repository struct to handle

func (*GormRepository) AddUserToGroup

func (repo *GormRepository) AddUserToGroup(userID uint, groupID uint) error

AddUserToGroup : Add user to an group

func (*GormRepository) CreateDevice

func (repo *GormRepository) CreateDevice(device *models.Device) (*models.Device, error)

CreateDevice : Create an device

func (*GormRepository) CreateGroup

func (repo *GormRepository) CreateGroup(group *models.Group) (*models.Group, error)

CreateGroup : Create an group

func (*GormRepository) CreateUser

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

CreateUser : Create an user

func (*GormRepository) DeleteDevice

func (repo *GormRepository) DeleteDevice(deviceID uint) error

DeleteDevice : Delete a device

func (*GormRepository) DeleteGroup

func (repo *GormRepository) DeleteGroup(groupID uint) error

DeleteGroup : Remove an group

func (*GormRepository) DeleteUser

func (repo *GormRepository) DeleteUser(userID uint) error

DeleteUser : Delete an user

func (*GormRepository) FindDevices

func (repo *GormRepository) FindDevices(where ...interface{}) ([]*models.Device, error)

FindDevices : Find all devices by pattern

func (*GormRepository) GetDevice

func (repo *GormRepository) GetDevice(id uint) (*models.Device, error)

GetDevice : Get a device by its id

func (*GormRepository) GetDevices

func (repo *GormRepository) GetDevices() ([]*models.Device, error)

GetDevices : Get all devices

func (*GormRepository) GetDevicesByUserID

func (repo *GormRepository) GetDevicesByUserID(userID uint) ([]*models.Device, error)

GetDevicesByUserID : Get all devices of the user

func (*GormRepository) GetGroup

func (repo *GormRepository) GetGroup(groupID uint) (*models.Group, error)

GetGroup : Get the group

func (*GormRepository) GetGroupByName

func (repo *GormRepository) GetGroupByName(name string) (*models.Group, error)

GetGroupByName : Get the group by its name

func (*GormRepository) GetGroupsByUser

func (repo *GormRepository) GetGroupsByUser(userID uint) (*[]models.Group, error)

GetGroupsByUser : Get all grous for an user

func (*GormRepository) GetLdapUsers

func (repo *GormRepository) GetLdapUsers() (*[]models.User, error)

GetLdapUsers : Get all ldap users

func (*GormRepository) GetUser

func (repo *GormRepository) GetUser(userID uint) (*models.User, error)

GetUser : Get the user with this id

func (*GormRepository) GetUserByUsername

func (repo *GormRepository) GetUserByUsername(username string) (*models.User, error)

GetUserByUsername : Get the user by the username

func (*GormRepository) GetUserWithDevices

func (repo *GormRepository) GetUserWithDevices(userID uint) (*models.User, error)

GetUserWithDevices : Get the user with his devices

func (*GormRepository) GetUsers

func (repo *GormRepository) GetUsers() (*[]models.User, error)

GetUsers : Get all users

func (*GormRepository) RemoveUserFromGroup

func (repo *GormRepository) RemoveUserFromGroup(userID uint, groupID uint) error

RemoveUserFromGroup : Remove an user from an group

func (*GormRepository) Sync

func (repo *GormRepository) Sync() (init bool, err error)

Sync : Synchronice database with migration and default settings

type GroupRepository

type GroupRepository interface {
	CreateGroup(*models.Group) (*models.Group, error)
	AddUserToGroup(userID uint, groupID uint) error
	RemoveUserFromGroup(userID uint, groupID uint) error
	GetGroup(uint) (*models.Group, error)
	GetGroupByName(name string) (*models.Group, error)
	GetGroupsByUser(userID uint) (*[]models.Group, error)
	DeleteGroup(groupID uint) error
}

GroupRepository : Group repository to predefine the interface

type Repository

type Repository interface {
	Sync() (bool, error)
	UserRepository
	GroupRepository
	DeviceRepository
}

Repository : Repository Interface to be implemented

func NewGormRepository

func NewGormRepository(db *gorm.DB, hub *hub.Hub) (Repository, error)

NewGormRepository : Create a new repository to handle orm operations

type UserRepository

type UserRepository interface {
	CreateUser(*models.User) (*models.User, error)
	GetUser(uint) (*models.User, error)
	GetUsers() (*[]models.User, error)
	GetLdapUsers() (*[]models.User, error)
	GetUserByUsername(string) (*models.User, error)
	GetUserWithDevices(uint) (*models.User, error)
	DeleteUser(userID uint) error
}

UserRepository : User repository to predifine the interfaces

Jump to

Keyboard shortcuts

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