datastore

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

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

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

Documentation

Index

Constants

View Source
const (
	StatusActive                        = 1
	StatusClaimed                       = 2
	StatusArchived                      = 3
	BusinessFunctionGrantFreeSubmission = 1
)
View Source
const (
	SortOrderAscending  = 1
	SortOrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Credit

type Credit struct {
	StoreID                    primitive.ObjectID `bson:"store_id" json:"store_id"`
	StoreName                  string             `bson:"store_name" json:"store_name"`
	StoreTimezone              string             `bson:"store_timezone" json:"store_timezone"`
	ID                         primitive.ObjectID `bson:"_id" json:"id"`
	UserName                   string             `bson:"user_name" json:"user_name"`
	UserLexicalName            string             `bson:"user_lexical_name" json:"user_lexical_name"`
	UserID                     primitive.ObjectID `bson:"user_id" json:"user_id"`
	BusinessFunction           int8               `bson:"business_function" json:"business_function"`
	OfferID                    primitive.ObjectID `bson:"offer_id" json:"offer_id"`
	OfferName                  string             `bson:"offer_name" json:"offer_name"`
	OfferServiceType           int8               `bson:"offer_service_type" json:"offer_service_type"`
	Status                     int8               `bson:"status" json:"status"`
	CreatedAt                  time.Time          `bson:"created_at,omitempty" json:"created_at,omitempty"`
	ModifiedAt                 time.Time          `bson:"modified_at,omitempty" json:"modified_at,omitempty"`
	ClaimedByComicSubmissionID primitive.ObjectID `bson:"claimed_by_comic_submission_id" json:"claimed_by_comic_submission_id"`
}

type CreditAsSelectOption

type CreditAsSelectOption 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 CreditListFilter

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

	// Filter related.
	StoreID          primitive.ObjectID
	UserID           primitive.ObjectID
	OfferID          primitive.ObjectID
	OfferServiceType int8
	Status           int8
	BusinessFunction int8
	SearchText       string
}

type CreditListResult

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

type CreditPaginationListFilter

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

	// Filter related.
	StoreID          primitive.ObjectID
	UserID           primitive.ObjectID
	OfferID          primitive.ObjectID
	OfferServiceType int8
	Status           int8
	BusinessFunction int8
	SearchText       string
}

type CreditPaginationListResult

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

CreditPaginationListResult represents the paginated list results for the associate records.

type CreditStorer

type CreditStorer interface {
	Create(ctx context.Context, m *Credit) error
	GetByID(ctx context.Context, id primitive.ObjectID) (*Credit, error)
	GetByName(ctx context.Context, name string) (*Credit, error)
	GetByPaymentProcessorCreditID(ctx context.Context, paymentProcessorCreditID string) (*Credit, error)
	GetNextAvailable(ctx context.Context, userID primitive.ObjectID, serviceType int8) (*Credit, error)
	UpdateByID(ctx context.Context, m *Credit) error
	ListByFilter(ctx context.Context, m *CreditPaginationListFilter) (*CreditPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *CreditPaginationListFilter) ([]*CreditAsSelectOption, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
}

CreditStorer Interface for store.

func NewDatastore

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

type CreditStorerImpl

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

func (CreditStorerImpl) CheckIfExistsByNameInOrgBranch

func (impl CreditStorerImpl) CheckIfExistsByNameInOrgBranch(ctx context.Context, name string, orgID primitive.ObjectID, branchID primitive.ObjectID) (bool, error)

func (CreditStorerImpl) Create

func (impl CreditStorerImpl) Create(ctx context.Context, u *Credit) error

func (CreditStorerImpl) DeleteByID

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

func (CreditStorerImpl) GetByID

func (impl CreditStorerImpl) GetByID(ctx context.Context, id primitive.ObjectID) (*Credit, error)

func (CreditStorerImpl) GetByName

func (impl CreditStorerImpl) GetByName(ctx context.Context, name string) (*Credit, error)

func (CreditStorerImpl) GetByPaymentProcessorCreditID

func (impl CreditStorerImpl) GetByPaymentProcessorCreditID(ctx context.Context, paymentProcessorCreditID string) (*Credit, error)

func (CreditStorerImpl) GetNextAvailable

func (impl CreditStorerImpl) GetNextAvailable(ctx context.Context, userID primitive.ObjectID, serviceType int8) (*Credit, error)

func (CreditStorerImpl) ListAsSelectOptionByFilter

func (impl CreditStorerImpl) ListAsSelectOptionByFilter(ctx context.Context, f *CreditPaginationListFilter) ([]*CreditAsSelectOption, error)

func (CreditStorerImpl) ListByFilter

func (CreditStorerImpl) UpdateByID

func (impl CreditStorerImpl) UpdateByID(ctx context.Context, m *Credit) error

Jump to

Keyboard shortcuts

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