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
	StatusError             = 2
	StatusArchived          = 3
	OwnershipTypeUser       = 1
	OwnershipTypeSubmission = 2
	OwnershipTypeStore      = 3
	ContentTypeFile         = 1
	ContentTypeImage        = 2
)
View Source
const (
	SortOrderAscending  = 1
	SortOrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	StoreID            primitive.ObjectID `bson:"store_id,omitempty" json:"store_id,omitempty"`
	StoreName          string             `bson:"store_name" json:"store_name"`
	StoreTimezone      string             `bson:"store_timezone" json:"store_timezone"`
	ID                 primitive.ObjectID `bson:"_id" json:"id"`
	CreatedAt          time.Time          `bson:"created_at,omitempty" json:"created_at,omitempty"`
	CreatedByUserName  string             `bson:"created_by_user_name" json:"created_by_user_name"`
	CreatedByUserID    primitive.ObjectID `bson:"created_by_user_id" json:"created_by_user_id"`
	ModifiedAt         time.Time          `bson:"modified_at,omitempty" json:"modified_at,omitempty"`
	ModifiedByUserName string             `bson:"modified_by_user_name" json:"modified_by_user_name"`
	ModifiedByUserID   primitive.ObjectID `bson:"modified_by_user_id" json:"modified_by_user_id"`
	Name               string             `bson:"name" json:"name"`
	Description        string             `bson:"description" json:"description"`
	Filename           string             `bson:"filename" json:"filename"`
	ObjectKey          string             `bson:"object_key" json:"object_key"`
	ObjectURL          string             `bson:"object_url" json:"object_url"`
	OwnershipID        primitive.ObjectID `bson:"ownership_id" json:"ownership_id"`
	OwnershipType      int8               `bson:"ownership_type" json:"ownership_type"`
	Status             int8               `bson:"status" json:"status"`
	ContentType        int8               `bson:"content_type" json:"content_type"`
}

type AttachmentAsSelectOption

type AttachmentAsSelectOption 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 AttachmentPaginationListFilter

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

	// Filter related.
	StoreID          primitive.ObjectID
	OwnershipID      primitive.ObjectID
	CreatedByUserID  primitive.ObjectID
	ModifiedByUserID primitive.ObjectID
	UserRole         int8
	ExcludeArchived  bool
}

type AttachmentPaginationListResult

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

AttachmentPaginationListResult represents the paginated list results for the associate records.

type AttachmentStorer

type AttachmentStorer interface {
	Create(ctx context.Context, m *Attachment) error
	GetByID(ctx context.Context, id primitive.ObjectID) (*Attachment, error)
	UpdateByID(ctx context.Context, m *Attachment) error
	ListByFilter(ctx context.Context, m *AttachmentPaginationListFilter) (*AttachmentPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *AttachmentPaginationListFilter) ([]*AttachmentAsSelectOption, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
}

AttachmentStorer Interface for attachment.

func NewDatastore

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

type AttachmentStorerImpl

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

func (AttachmentStorerImpl) Create

func (impl AttachmentStorerImpl) Create(ctx context.Context, u *Attachment) error

func (AttachmentStorerImpl) DeleteByID

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

func (AttachmentStorerImpl) GetByID

func (AttachmentStorerImpl) ListAsSelectOptionByFilter

func (AttachmentStorerImpl) UpdateByID

func (impl AttachmentStorerImpl) UpdateByID(ctx context.Context, m *Attachment) error

Jump to

Keyboard shortcuts

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