datastore

package
v0.0.0-...-75c6f16 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	StatusActive   = 1
	StatusArchived = 2

	CategoryUnspecified      = 1
	CategoryGovernmentCanada = 2
)
View Source
const (
	OrderAscending  = 1
	OrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SmartFolder

type SmartFolder struct {
	ID                    primitive.ObjectID `bson:"_id" json:"id"`
	Name                  string             `bson:"name" json:"name"`
	Category              uint64             `bson:"category,omitempty" json:"category,omitempty"`
	SubCategory           uint64             `bson:"sub_category,omitempty" json:"sub_category,omitempty"`
	SortNumber            int8               `bson:"sort_number" json:"sort_number"`
	Description           string             `bson:"description" json:"description"`
	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"`
	TenantID              primitive.ObjectID `bson:"tenant_id" json:"tenant_id"`
	TenantName            string             `bson:"tenant_name" json:"tenant_name"`
}

type SmartFolderAsSelectOption

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

type SmartFolderListResult

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

type SmartFolderPaginationListFilter

type SmartFolderPaginationListFilter 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 SmartFolderPaginationListResult

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

SmartFolderPaginationListResult represents the paginated list results for the associate records.

type SmartFolderStorer

type SmartFolderStorer interface {
	Create(ctx context.Context, m *SmartFolder) error
	CreateOrGetByID(ctx context.Context, hh *SmartFolder) (*SmartFolder, error)
	GetByID(ctx context.Context, id primitive.ObjectID) (*SmartFolder, error)
	GetByPublicID(ctx context.Context, oldID uint64) (*SmartFolder, error)
	GetByText(ctx context.Context, text string) (*SmartFolder, error)
	GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*SmartFolder, error)
	CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)
	UpdateByID(ctx context.Context, m *SmartFolder) error
	ListByFilter(ctx context.Context, f *SmartFolderPaginationListFilter) (*SmartFolderPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *SmartFolderPaginationListFilter) ([]*SmartFolderAsSelectOption, error)
	ListByTenantID(ctx context.Context, tid primitive.ObjectID) (*SmartFolderPaginationListResult, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
}

SmartFolderStorer Interface for user.

func NewDatastore

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

type SmartFolderStorerImpl

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

func (SmartFolderStorerImpl) CheckIfExistsByEmail

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

func (SmartFolderStorerImpl) Create

func (impl SmartFolderStorerImpl) Create(ctx context.Context, u *SmartFolder) error

func (SmartFolderStorerImpl) CreateOrGetByID

func (impl SmartFolderStorerImpl) CreateOrGetByID(ctx context.Context, hh *SmartFolder) (*SmartFolder, error)

func (SmartFolderStorerImpl) DeleteByID

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

func (SmartFolderStorerImpl) GetByID

func (SmartFolderStorerImpl) GetByPublicID

func (impl SmartFolderStorerImpl) GetByPublicID(ctx context.Context, oldID uint64) (*SmartFolder, error)

func (SmartFolderStorerImpl) GetByText

func (impl SmartFolderStorerImpl) GetByText(ctx context.Context, text string) (*SmartFolder, error)

func (SmartFolderStorerImpl) GetLatestByTenantID

func (impl SmartFolderStorerImpl) GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*SmartFolder, error)

func (SmartFolderStorerImpl) ListAsSelectOptionByFilter

func (SmartFolderStorerImpl) ListByTenantID

func (SmartFolderStorerImpl) UpdateByID

func (impl SmartFolderStorerImpl) UpdateByID(ctx context.Context, m *SmartFolder) error

Jump to

Keyboard shortcuts

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