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 (
	BulletinStatusActive   = 1
	BulletinStatusArchived = 2
)
View Source
const (
	OrderAscending  = 1
	OrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bulletin

type Bulletin struct {
	ID                    primitive.ObjectID `bson:"_id" json:"id"`
	TenantID              primitive.ObjectID `bson:"tenant_id" json:"tenant_id,omitempty"`
	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"`
	Text                  string             `bson:"text" json:"text"`
	Status                int8               `bson:"status" json:"status"`
	PublicID              uint64             `bson:"public_id" json:"public_id"`
}

type BulletinAsSelectOption

type BulletinAsSelectOption 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 BulletinListFilter

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

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

type BulletinListResult

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

type BulletinPaginationListFilter

type BulletinPaginationListFilter 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 BulletinPaginationListResult

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

BulletinPaginationListResult represents the paginated list results for the associate records.

type BulletinStorer

type BulletinStorer interface {
	Create(ctx context.Context, m *Bulletin) error
	GetByID(ctx context.Context, id primitive.ObjectID) (*Bulletin, error)
	GetByPublicID(ctx context.Context, oldID uint64) (*Bulletin, error)
	GetByEmail(ctx context.Context, email string) (*Bulletin, error)
	GetByVerificationCode(ctx context.Context, verificationCode string) (*Bulletin, error)
	GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*Bulletin, error)
	CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)
	UpdateByID(ctx context.Context, m *Bulletin) error
	ListByFilter(ctx context.Context, f *BulletinPaginationListFilter) (*BulletinPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *BulletinListFilter) ([]*BulletinAsSelectOption, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
}

BulletinStorer Interface for user.

func NewDatastore

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

type BulletinStorerImpl

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

func (BulletinStorerImpl) CheckIfExistsByEmail

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

func (BulletinStorerImpl) Create

func (impl BulletinStorerImpl) Create(ctx context.Context, u *Bulletin) error

func (BulletinStorerImpl) DeleteByID

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

func (BulletinStorerImpl) GetByEmail

func (impl BulletinStorerImpl) GetByEmail(ctx context.Context, email string) (*Bulletin, error)

func (BulletinStorerImpl) GetByID

func (BulletinStorerImpl) GetByPublicID

func (impl BulletinStorerImpl) GetByPublicID(ctx context.Context, oldID uint64) (*Bulletin, error)

func (BulletinStorerImpl) GetByVerificationCode

func (impl BulletinStorerImpl) GetByVerificationCode(ctx context.Context, verificationCode string) (*Bulletin, error)

func (BulletinStorerImpl) GetLatestByTenantID

func (impl BulletinStorerImpl) GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*Bulletin, error)

func (BulletinStorerImpl) ListAsSelectOptionByFilter

func (impl BulletinStorerImpl) ListAsSelectOptionByFilter(ctx context.Context, f *BulletinListFilter) ([]*BulletinAsSelectOption, error)

func (BulletinStorerImpl) ListByFilter

func (BulletinStorerImpl) UpdateByID

func (impl BulletinStorerImpl) UpdateByID(ctx context.Context, m *Bulletin) error

Jump to

Keyboard shortcuts

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