report

package
v0.0.0-...-3bd2bae Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound abstracts the  not found error.
	ErrNotFound = errors.New("Entity not found")

	// ErrInvalidID occurs when an ID is not in a valid form.
	ErrInvalidID = errors.New("ID is not in its proper form")

	// ErrAuthenticationFailure occurs when a user attempts to authenticate but
	// anything goes wrong.
	ErrAuthenticationFailure = errors.New("Authentication failed")

	// ErrForbidden occurs when a user tries to do something that is forbidden to them according to our access control policies.
	ErrForbidden = errors.New("Attempted action is not allowed")
)
View Source
var Components = make(map[string]ComponentFactory)

Functions

func Delete

func Delete(ctx context.Context, dbConn *db.MongoDB, id string) error

Delete removes a user from the database.

func Deleted

func Deleted() func(*ListOpts)

func EnsureIndex

func EnsureIndex(ctx context.Context, dbConn *db.MongoDB) error

func Limit

func Limit(i int) func(*ListOpts)

func NewListOpts

func NewListOpts() []func(*ListOpts)

func Offset

func Offset(i int) func(*ListOpts)

func OrgID

func OrgID(s string) func(*ListOpts)

func Status

func Status(s string) func(*ListOpts)

func Update

func Update(ctx context.Context, dbConn *db.MongoDB, id string, upd *Report, now time.Time) error

Update replaces a report document in the database.

func UserID

func UserID(s string) func(*ListOpts)

Types

type CmpArticleView

type CmpArticleView struct {
	Type string           `json:"type" default:"article-view"`
	Body article.Document `json:"body"`
}

func (CmpArticleView) Kind

func (c CmpArticleView) Kind() string

func (CmpArticleView) Payload

func (c CmpArticleView) Payload() interface{}

type CmpArticles

type CmpArticles struct {
	Type string             `json:"type" default:"articles"`
	Body []article.Document `json:"body"`
}

func (CmpArticles) Kind

func (c CmpArticles) Kind() string

func (CmpArticles) Payload

func (c CmpArticles) Payload() interface{}

type CmpHTML

type CmpHTML struct {
	Type string `json:"type" default:"html"`
	Body string `json:"body"`
}

func (CmpHTML) Kind

func (c CmpHTML) Kind() string

func (CmpHTML) Payload

func (c CmpHTML) Payload() interface{}

type CmpMarkdown

type CmpMarkdown struct {
	Type string `json:"type" default:"markdown"`
	Body string `json:"body"`
}

func (CmpMarkdown) Kind

func (c CmpMarkdown) Kind() string

func (CmpMarkdown) Payload

func (c CmpMarkdown) Payload() interface{}

type CmpTags

type CmpTags struct {
	Type string   `json:"type" default:"tags"`
	Body []string `json:"body"`
}

func (CmpTags) Kind

func (c CmpTags) Kind() string

func (CmpTags) Payload

func (c CmpTags) Payload() interface{}

type CmpText

type CmpText struct {
	Type string `json:"type" default:"text"`
	Body string `json:"body"`
}

func (CmpText) Kind

func (c CmpText) Kind() string

func (CmpText) Payload

func (c CmpText) Payload() interface{}

type CmpTimeline

type CmpTimeline struct {
	Type string             `json:"type" default:"timeline"`
	Body []article.Document `json:"body"`
}

func (CmpTimeline) Kind

func (c CmpTimeline) Kind() string

func (CmpTimeline) Payload

func (c CmpTimeline) Payload() interface{}

type Component

type Component interface {
	Kind() string
	Payload() interface{}
}

func NewCmpArticleView

func NewCmpArticleView() (Component, error)

func NewCmpArticles

func NewCmpArticles() (Component, error)

func NewCmpHTML

func NewCmpHTML() (Component, error)

func NewCmpMarkdown

func NewCmpMarkdown() (Component, error)

func NewCmpTags

func NewCmpTags() (Component, error)

func NewCmpText

func NewCmpText() (Component, error)

func NewCmpTimeline

func NewCmpTimeline() (Component, error)

type ComponentFactory

type ComponentFactory func() (Component, error)

type ListOpts

type ListOpts struct {
	Limit   int
	Offset  int
	Deleted bool
	OrgID   primitive.ObjectID
	UserID  primitive.ObjectID
	Status  string
}

func DefaultOpts

func DefaultOpts() ListOpts

type Pagination

type Pagination struct {
	Total int64 `json:"total"`
	Pages int64 `json:"pages"`
}

func GetPagination

func GetPagination(ctx context.Context, dbConn *db.MongoDB, filter bson.M, limit int, collection string) (*Pagination, error)

GetPagination paginate documents with query

type Report

type Report struct {
	ID primitive.ObjectID `bson:"_id" json:"id"`

	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
	Deleted   bool      `json:"-" bson:"deleted"`

	UserID     string             `json:"-"`
	OrgID      string             `json:"-"`
	Title      string             `json:"title" bson:"title"`
	Style      string             `json:"style"`
	Articles   []article.Document `json:"articles"`
	Components []Component        `json:"components" bson:"components"`
}

func Create

func Create(ctx context.Context, dbConn *db.MongoDB, nr *Report, now time.Time) (*Report, error)

Create inserts a new user into the database.

func Get

func Get(ctx context.Context, dbConn *db.MongoDB, id string) (*Report, error)

Get gets the specified user from the database.

type ReportsList

type ReportsList struct {
	Data       []*Report   `json:"data"`
	Pagination *Pagination `json:"pagination"`
}

ReportsList of Report

func List

func List(ctx context.Context, dbConn *db.MongoDB, optionsList ...func(*db.ListOpts)) (*ReportsList, error)

List retrieves a list of existing report from the database.

Jump to

Keyboard shortcuts

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