package models import "context" // A Group is a collection of lights that relates to one another. The API should // allow all lights within it. type Group struct { ID int `json:"id" db:"id"` Name string `json:"name" db:"name"` Permissions []GroupPermission `json:"permissions" db:"-"` } // A GroupPermission is a permission for a user in a group. type GroupPermission struct { GroupID int `json:"group_id" db:"group_id"` UserID int `json:"user_id" db:"user_id"` Read bool `json:"read" db:"read"` Write bool `json:"write" db:"write"` Create bool `json:"create" db:"create"` Delete bool `json:"delete" db:"delete"` Manage bool `json:"manage" db:"manage"` } // GroupRepository is an interface for all database operations // the Group model makes. type GroupRepository interface { FindByID(ctx context.Context, id int) (Group, error) FindByLight(ctx context.Context, light Light) (Group, error) List(ctx context.Context) ([]Group, error) ListByUser(ctx context.Context, user User) ([]Group, error) UpdatePermissions(ctx context.Context, permission GroupPermission) error Insert(ctx context.Context, group Group) (Group, error) Update(ctx context.Context, group Group) error Remove(ctx context.Context, group Group) error }