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: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusActive   = 1
	StatusArchived = 2
)
View Source
const (
	OrderAscending  = 1
	OrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ServiceFee

type ServiceFee struct {
	ID                    primitive.ObjectID `bson:"_id" json:"id"`
	TenantID              primitive.ObjectID `bson:"tenant_id" json:"tenant_id,omitempty"`
	Name                  string             `bson:"name" json:"name"`
	Description           string             `bson:"description" json:"description"`
	Percentage            float64            `bson:"percentage" json:"percentage"`
	Status                int8               `bson:"status" json:"status"`
	PublicID              uint64             `bson:"public_id" json:"public_id"`
	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 ServiceFeeAsSelectOption

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

type ServiceFeeListFilter

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

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

type ServiceFeeListResult

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

type ServiceFeePaginationListAndCountResult

type ServiceFeePaginationListAndCountResult struct {
	Results     []*ServiceFee `json:"results"`
	NextCursor  string        `json:"next_cursor"`
	HasNextPage bool          `json:"has_next_page"`
	Count       int64         `json:"count"`
}

ServiceFeePaginationListResult represents the paginated list results for the ServiceFee records (meaning limited).

type ServiceFeePaginationListFilter

type ServiceFeePaginationListFilter 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 ServiceFeePaginationListResult

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

ServiceFeePaginationListResult represents the paginated list results for the associate records.

type ServiceFeeStorer

type ServiceFeeStorer interface {
	Create(ctx context.Context, m *ServiceFee) error
	GetByID(ctx context.Context, id primitive.ObjectID) (*ServiceFee, error)
	GetByPublicID(ctx context.Context, oldID uint64) (*ServiceFee, error)
	GetByEmail(ctx context.Context, email string) (*ServiceFee, error)
	GetByVerificationCode(ctx context.Context, verificationCode string) (*ServiceFee, error)
	GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*ServiceFee, error)
	CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)
	UpdateByID(ctx context.Context, m *ServiceFee) error
	ListByFilter(ctx context.Context, f *ServiceFeePaginationListFilter) (*ServiceFeePaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *ServiceFeePaginationListFilter) ([]*ServiceFeeAsSelectOption, error)
	CountByFilter(ctx context.Context, f *ServiceFeePaginationListFilter) (int64, error)
	ListAndCountByFilter(ctx context.Context, f *ServiceFeePaginationListFilter) (*ServiceFeePaginationListAndCountResult, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
}

ServiceFeeStorer Interface for user.

func NewDatastore

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

type ServiceFeeStorerImpl

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

func (ServiceFeeStorerImpl) CheckIfExistsByEmail

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

func (ServiceFeeStorerImpl) CountByFilter

func (ServiceFeeStorerImpl) Create

func (impl ServiceFeeStorerImpl) Create(ctx context.Context, u *ServiceFee) error

func (ServiceFeeStorerImpl) DeleteByID

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

func (ServiceFeeStorerImpl) GetByEmail

func (impl ServiceFeeStorerImpl) GetByEmail(ctx context.Context, email string) (*ServiceFee, error)

func (ServiceFeeStorerImpl) GetByID

func (ServiceFeeStorerImpl) GetByPublicID

func (impl ServiceFeeStorerImpl) GetByPublicID(ctx context.Context, oldID uint64) (*ServiceFee, error)

func (ServiceFeeStorerImpl) GetByVerificationCode

func (impl ServiceFeeStorerImpl) GetByVerificationCode(ctx context.Context, verificationCode string) (*ServiceFee, error)

func (ServiceFeeStorerImpl) GetLatestByTenantID

func (impl ServiceFeeStorerImpl) GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*ServiceFee, error)

func (ServiceFeeStorerImpl) ListAsSelectOptionByFilter

func (ServiceFeeStorerImpl) UpdateByID

func (impl ServiceFeeStorerImpl) UpdateByID(ctx context.Context, m *ServiceFee) error

Jump to

Keyboard shortcuts

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