mongodb

package
v0.0.0-...-9b13959 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(
	dto habitapi.DTO,
	collectionName string,
	db *mongo.Database,
) (interface{}, bson.ObjectID, error)

func Delete

func Delete(
	id string,
	collectionName string,
	db *mongo.Database,
) error

func GetById

func GetById(
	id string,
	collectionName string,
	empty interface{},
	db *mongo.Database,
) (interface{}, error)

func InitMongo

func InitMongo(mongo_uri string, credential Credential) (*mongo.Client, error)

func List

func List[T any](
	collectionName string,
	empty []*T,
	db *mongo.Database,
) ([]*T, error)

func Update

func Update(
	id string,
	dto habitapi.DTO,
	collectionName string,
	db *mongo.Database,
) (interface{}, error)

Types

type Credential

type Credential struct {
	Username string
	Password string
}

type DeedService

type DeedService struct {
	DB             *mongo.Database
	CollectionName string
}

func (*DeedService) Create

func (s *DeedService) Create(dto habitapi.CreateDeedDTO) (*habitapi.Deed, error)

func (*DeedService) Delete

func (s *DeedService) Delete(id string) error

func (*DeedService) GetById

func (s *DeedService) GetById(id string) (*habitapi.Deed, error)

func (*DeedService) List

func (s *DeedService) List() ([]*habitapi.Deed, error)

func (*DeedService) Update

func (s *DeedService) Update(
	id string, dto habitapi.UpdateDeedDTO,
) (*habitapi.Deed, error)

type HabitGroupService

type HabitGroupService struct {
	DB             *mongo.Database
	CollectionName string
}

func (*HabitGroupService) Create

func (*HabitGroupService) Delete

func (s *HabitGroupService) Delete(id string) error

func (*HabitGroupService) GetById

func (s *HabitGroupService) GetById(id string) (*habitapi.HabitGroup, error)

func (*HabitGroupService) List

func (s *HabitGroupService) List() ([]*habitapi.HabitGroup, error)

func (*HabitGroupService) Update

type HabitService

type HabitService struct {
	DB             *mongo.Database
	CollectionName string
}

func (*HabitService) Create

func (*HabitService) Delete

func (s *HabitService) Delete(id string) error

func (*HabitService) GetById

func (s *HabitService) GetById(id string) (*habitapi.Habit, error)

func (*HabitService) List

func (s *HabitService) List() ([]*habitapi.Habit, error)

func (*HabitService) Update

func (s *HabitService) Update(
	id string, dto habitapi.UpdateHabitDTO,
) (*habitapi.Habit, error)

type RewardService

type RewardService struct {
	DB             *mongo.Database
	CollectionName string
}

func (*RewardService) Create

func (*RewardService) Delete

func (s *RewardService) Delete(id string) error

func (*RewardService) GetById

func (s *RewardService) GetById(id string) (*habitapi.Reward, error)

func (*RewardService) List

func (s *RewardService) List() ([]*habitapi.Reward, error)

func (*RewardService) Update

func (s *RewardService) Update(
	id string, dto habitapi.UpdateRewardDTO,
) (*habitapi.Reward, error)

type UserService

type UserService struct {
	DB             *mongo.Database
	CollectionName string
}

func (*UserService) Create

func (s *UserService) Create(dto habitapi.CreateUserDTO) (*habitapi.User, error)

func (*UserService) Delete

func (s *UserService) Delete(id string) error

func (*UserService) GetById

func (s *UserService) GetById(id string) (*habitapi.User, error)

func (*UserService) List

func (s *UserService) List() ([]*habitapi.User, error)

func (*UserService) Update

func (s *UserService) Update(
	id string, dto habitapi.UpdateUserDTO,
) (*habitapi.User, error)

Jump to

Keyboard shortcuts

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