Documentation
¶
Index ¶
- Constants
- type BlacklistService
- type DBClient
- type DBCollection
- type DBCursor
- type DBHandler
- func (h *DBHandler[T]) DeleteMany(filter T) (T, error)
- func (h *DBHandler[T]) DeleteOne(filter T) (T, error)
- func (h *DBHandler[T]) FindMany(filter T) ([]T, error)
- func (h *DBHandler[T]) FindOne(filter T) (T, error)
- func (h *DBHandler[T]) FindOneAsync(tCh chan T, eCh chan error, filter T, wg *sync.WaitGroup)
- func (h *DBHandler[T]) InsertOne(m T) (T, error)
- func (h *DBHandler[T]) UpdateOne(filter T, m T) (T, error)
- type FileService
- func (p *FileService) FileCreate(g *models.File, content []byte) (*models.File, error)
- func (p *FileService) FileDelete(g *models.File) (*models.File, error)
- func (p *FileService) FileDeleteMany(g []*models.File) error
- func (p *FileService) FileFind(g *models.File) (*models.File, error)
- func (p *FileService) FileUpdate(g *models.File, content []byte) (*models.File, error)
- func (p *FileService) FilesFind(g *models.File) ([]*models.File, error)
- func (p *FileService) RetrieveFile(g *models.File) (*bytes.Buffer, error)
- type GroupService
- func (p *GroupService) GroupCreate(g *models.Group) (*models.Group, error)
- func (p *GroupService) GroupDelete(g *models.Group) (*models.Group, error)
- func (p *GroupService) GroupDeleteMany(g *models.Group) (*models.Group, error)
- func (p *GroupService) GroupDocInsert(g *models.Group) (*models.Group, error)
- func (p *GroupService) GroupFind(g *models.Group) (*models.Group, error)
- func (p *GroupService) GroupUpdate(g *models.Group) (*models.Group, error)
- func (p *GroupService) GroupsFind(g *models.Group) ([]*models.Group, error)
- type TaskService
- func (p *TaskService) TaskCreate(g *models.Task) (*models.Task, error)
- func (p *TaskService) TaskDelete(g *models.Task) (*models.Task, error)
- func (p *TaskService) TaskDeleteMany(g *models.Task) (*models.Task, error)
- func (p *TaskService) TaskDocInsert(g *models.Task) (*models.Task, error)
- func (p *TaskService) TaskFind(g *models.Task) (*models.Task, error)
- func (p *TaskService) TaskUpdate(g *models.Task) (*models.Task, error)
- func (p *TaskService) TasksFind(g *models.Task) ([]*models.Task, error)
- type UserService
- func (p *UserService) AuthenticateUser(u *models.User) (*models.User, error)
- func (p *UserService) UpdatePassword(u *models.User, currentPassword string, newPassword string) (*models.User, error)
- func (p *UserService) UserCreate(u *models.User) (*models.User, error)
- func (p *UserService) UserDelete(u *models.User) (*models.User, error)
- func (p *UserService) UserDeleteMany(u *models.User) (*models.User, error)
- func (p *UserService) UserDocInsert(u *models.User) (*models.User, error)
- func (p *UserService) UserFind(u *models.User) (*models.User, error)
- func (p *UserService) UserUpdate(u *models.User) (*models.User, error)
- func (p *UserService) UsersFind(u *models.User) ([]*models.User, error)
Constants ¶
const ( FindOne routineType = iota UpdateOne InsertOne DeleteOne )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlacklistService ¶
type BlacklistService struct {
// contains filtered or unexported fields
}
BlacklistService is used by the app to manage all group related controllers and functionality
func NewBlacklistService ¶
func NewBlacklistService(db DBClient, handler *DBHandler[*blacklistModel]) *BlacklistService
NewBlacklistService is an exported function used to initialize a new GroupService struct
func (*BlacklistService) BlacklistAuthToken ¶
func (a *BlacklistService) BlacklistAuthToken(authToken string) error
BlacklistAuthToken is used during sign-out to add the now invalid auth-token/api key to the blacklist collection
func (*BlacklistService) CheckTokenBlacklist ¶
func (a *BlacklistService) CheckTokenBlacklist(authToken string) bool
CheckTokenBlacklist to determine if the submitted Auth-Token or API-Key with what's in the blacklist collection
type DBClient ¶
type DBClient interface { Connect() error Close() error GetBucket(bucketName string) (*gridfs.Bucket, error) GetCollection(collectionName string) DBCollection NewDBHandler(collectionName string) *DBHandler[dbModel] NewUserHandler() *DBHandler[*userModel] NewGroupHandler() *DBHandler[*groupModel] NewBlacklistHandler() *DBHandler[*blacklistModel] NewTaskHandler() *DBHandler[*taskModel] NewFileHandler() *DBHandler[*fileModel] }
DBClient is an abstraction of the dbClient and testDBClient types
func InitializeNewClient ¶
InitializeNewClient returns an initialized DBClient based on the ENV
type DBCollection ¶
type DBCollection interface { InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) UpdateByID(ctx context.Context, id interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (cur *mongo.Cursor, err error) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) }
DBCollection is an abstraction of the dbClient and testDBClient types
type DBCursor ¶
type DBCursor interface { Next(ctx context.Context) bool Decode(val interface{}) error Close(ctx context.Context) error }
DBCursor is an abstraction of the dbClient and testDBClient types
type DBHandler ¶
type DBHandler[T dbModel] struct {
// contains filtered or unexported fields
}
DBHandler is a Generic type struct for organizing dbModel methods
func (*DBHandler[T]) DeleteMany ¶
DeleteMany adds a new dbModel record to a collection
func (*DBHandler[T]) FindMany ¶
FindMany is used to get a slice of dbModels from the db with custom filter
func (*DBHandler[T]) FindOneAsync ¶
FindOneAsync is used to get a dbModel from the db with custom filter
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
FileService is used by the app to manage all File related controllers and functionality
func NewFileService ¶
func NewFileService(db DBClient, fHandler *DBHandler[*fileModel], uHandler *DBHandler[*userModel], gHandler *DBHandler[*groupModel]) *FileService
NewFileService is an exported function used to initialize a new FileService struct
func (*FileService) FileCreate ¶
FileCreate creates a new GridFS File
func (*FileService) FileDelete ¶
FileDelete is used to delete a GridFS File
func (*FileService) FileDeleteMany ¶
func (p *FileService) FileDeleteMany(g []*models.File) error
FileDeleteMany is used to delete a GridFS File
func (*FileService) FileUpdate ¶
FileUpdate is used to update an existing File
func (*FileService) RetrieveFile ¶
RetrieveFile returns the content bytes for a GridFS File
type GroupService ¶
type GroupService struct {
// contains filtered or unexported fields
}
GroupService is used by the app to manage all group related controllers and functionality
func NewGroupService ¶
func NewGroupService(db DBClient, handler *DBHandler[*groupModel]) *GroupService
NewGroupService is an exported function used to initialize a new GroupService struct
func (*GroupService) GroupCreate ¶
GroupCreate is used to create a new user group
func (*GroupService) GroupDelete ¶
GroupDelete is used to delete a group doc
func (*GroupService) GroupDeleteMany ¶
GroupDeleteMany is used to delete many Groups
func (*GroupService) GroupDocInsert ¶
GroupDocInsert is used to insert a group doc directly into mongodb for testing purposes
func (*GroupService) GroupUpdate ¶
GroupUpdate is used to update an existing group
func (*GroupService) GroupsFind ¶
GroupsFind is used to find all group docs in a MongoDB Collection
type TaskService ¶
type TaskService struct {
// contains filtered or unexported fields
}
TaskService is used by the app to manage all Task related controllers and functionality
func NewTaskService ¶
func NewTaskService(db DBClient, tHandler *DBHandler[*taskModel], uHandler *DBHandler[*userModel], gHandler *DBHandler[*groupModel]) *TaskService
NewTaskService is an exported function used to initialize a new TaskService struct
func (*TaskService) TaskCreate ¶
TaskCreate is used to create a new user Task
func (*TaskService) TaskDelete ¶
TaskDelete is used to delete a Task doc
func (*TaskService) TaskDeleteMany ¶
TaskDeleteMany is used to delete many Tasks
func (*TaskService) TaskDocInsert ¶
TaskDocInsert is used to insert a Task doc directly into mongodb for testing purposes
func (*TaskService) TaskUpdate ¶
TaskUpdate is used to update an existing Task
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService is used by the app to manage all user related controllers and functionality
func NewUserService ¶
func NewUserService(db DBClient, uHandler *DBHandler[*userModel], gHandler *DBHandler[*groupModel]) *UserService
NewUserService is an exported function used to initialize a new UserService struct
func (*UserService) AuthenticateUser ¶
AuthenticateUser is used to authenticate users that are signing in
func (*UserService) UpdatePassword ¶
func (p *UserService) UpdatePassword(u *models.User, currentPassword string, newPassword string) (*models.User, error)
UpdatePassword is used to update the currently logged-in user's password
func (*UserService) UserCreate ¶
UserCreate is used to create a new user
func (*UserService) UserDelete ¶
UserDelete is used to delete an User
func (*UserService) UserDeleteMany ¶
UserDeleteMany is used to delete many Users
func (*UserService) UserDocInsert ¶
UserDocInsert is used to insert user doc directly into mongodb for testing purposes
func (*UserService) UserUpdate ¶
UserUpdate is used to update an existing user doc