datastore

package
v0.0.0-...-ee53a0f Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SkillSetStatusActive   = 1
	SkillSetStatusArchived = 2
	SkillSetRoleRoot       = 1
	SkillSetRoleRetailer   = 2
	SkillSetRoleCustomer   = 3
)
View Source
const (
	OrderAscending  = 1
	OrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SkillSet

type SkillSet struct {
	ID                    primitive.ObjectID              `bson:"_id" json:"id"`
	TenantID              primitive.ObjectID              `bson:"tenant_id" json:"tenant_id,omitempty"`
	Category              string                          `bson:"category" json:"category"`
	SubCategory           string                          `bson:"sub_category" json:"sub_category"`
	Description           string                          `bson:"description" json:"description"`
	Status                int8                            `bson:"status" json:"status"`
	PublicID              uint64                          `bson:"public_id" json:"public_id"`
	InsuranceRequirements []*SkillSetInsuranceRequirement `bson:"insurance_requirements" json:"insurance_requirements,omitempty"` // Reference
	CreatedAt             time.Time                       `bson:"created_at" json:"created_at"`
	CreatedByUserID       primitive.ObjectID              `bson:"created_by_user_id" json:"created_by_user_id,omitempty"`
	CreatedByUserName     string                          `bson:"created_by_user_name" json:"created_by_user_name"`
	CreatedFromIPAddress  string                          `bson:"created_from_ip_address" json:"created_from_ip_address"`
	ModifiedAt            time.Time                       `bson:"modified_at" json:"modified_at"`
	ModifiedByUserID      primitive.ObjectID              `bson:"modified_by_user_id" json:"modified_by_user_id,omitempty"`
	ModifiedByUserName    string                          `bson:"modified_by_user_name" json:"modified_by_user_name"`
	ModifiedFromIPAddress string                          `bson:"modified_from_ip_address" json:"modified_from_ip_address"`
}

type SkillSetAsSelectOption

type SkillSetAsSelectOption struct {
	Value primitive.ObjectID `bson:"_id" json:"value"` // Extract from the database `_id` field and output through API as `value`.
	Label string             `bson:"sub_category" json:"label"`
}

type SkillSetInsuranceRequirement

type SkillSetInsuranceRequirement struct {
	SkillSetID  primitive.ObjectID `bson:"skill_set_id" json:"skill_set_id"`
	TenantID    primitive.ObjectID `bson:"tenant_id" json:"tenant_id"`
	ID          primitive.ObjectID `bson:"_id" json:"id"`
	PublicID    uint64             `bson:"public_id" json:"public_id"`
	Name        string             `bson:"name" json:"name"`
	Description string             `bson:"description" json:"description"`
	Status      int8               `bson:"status" json:"status"`
}

SkillSetInsuranceRequirement structure is a copy of `InsuranceRequirement` with extra `SkillSetID` field.

type SkillSetListFilter

type SkillSetListFilter struct {
	// Pagination related.
	Cursor    primitive.ObjectID
	PageSize  int64
	SortField string
	SortOrder int8 // 1=ascending | -1=descending

	// Filter related.
	TenantID        primitive.ObjectID
	Role            int8
	Status          int8
	UUIDs           []string
	ExcludeArchived bool
	SearchText      string
	FirstName       string
	LastName        string
	Email           string
	Phone           string
	CreatedAtGTE    time.Time
}

type SkillSetListResult

type SkillSetListResult struct {
	Results     []*SkillSet        `json:"results"`
	NextCursor  primitive.ObjectID `json:"next_cursor"`
	HasNextPage bool               `json:"has_next_page"`
}

type SkillSetPaginationListFilter

type SkillSetPaginationListFilter struct {
	// Pagination related.
	Cursor    string
	PageSize  int64
	SortField string
	SortOrder int8 // 1=ascending | -1=descending

	// Filter related.
	TenantID   primitive.ObjectID
	Status     int8
	SearchText string
}

type SkillSetPaginationListResult

type SkillSetPaginationListResult struct {
	Results     []*SkillSet `json:"results"`
	NextCursor  string      `json:"next_cursor"`
	HasNextPage bool        `json:"has_next_page"`
}

SkillSetPaginationListResult represents the paginated list results for the associate records.

type SkillSetStorer

type SkillSetStorer interface {
	Create(ctx context.Context, m *SkillSet) error
	GetByID(ctx context.Context, id primitive.ObjectID) (*SkillSet, error)
	GetByPublicID(ctx context.Context, oldID uint64) (*SkillSet, error)
	GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*SkillSet, error)
	CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)
	UpdateByID(ctx context.Context, m *SkillSet) error
	ListByFilter(ctx context.Context, f *SkillSetPaginationListFilter) (*SkillSetPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *SkillSetListFilter) ([]*SkillSetAsSelectOption, error)
	ListByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*SkillSetPaginationListResult, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
}

SkillSetStorer Interface for user.

func NewDatastore

func NewDatastore(appCfg *c.Conf, loggerp *slog.Logger, client *mongo.Client) SkillSetStorer

type SkillSetStorerImpl

type SkillSetStorerImpl struct {
	Logger     *slog.Logger
	DbClient   *mongo.Client
	Collection *mongo.Collection
}

func (SkillSetStorerImpl) CheckIfExistsByEmail

func (impl SkillSetStorerImpl) CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)

func (SkillSetStorerImpl) Create

func (impl SkillSetStorerImpl) Create(ctx context.Context, u *SkillSet) error

func (SkillSetStorerImpl) DeleteByID

func (impl SkillSetStorerImpl) DeleteByID(ctx context.Context, id primitive.ObjectID) error

func (SkillSetStorerImpl) GetByID

func (SkillSetStorerImpl) GetByPublicID

func (impl SkillSetStorerImpl) GetByPublicID(ctx context.Context, oldID uint64) (*SkillSet, error)

func (SkillSetStorerImpl) GetLatestByTenantID

func (impl SkillSetStorerImpl) GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*SkillSet, error)

func (SkillSetStorerImpl) ListAsSelectOptionByFilter

func (impl SkillSetStorerImpl) ListAsSelectOptionByFilter(ctx context.Context, f *SkillSetListFilter) ([]*SkillSetAsSelectOption, error)

func (SkillSetStorerImpl) ListByFilter

func (SkillSetStorerImpl) ListByTenantID

func (SkillSetStorerImpl) UpdateByID

func (impl SkillSetStorerImpl) UpdateByID(ctx context.Context, m *SkillSet) error

Jump to

Keyboard shortcuts

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