libdocuments

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBacklinks(ctx context.Context, content string, links []string) (newContent string, err error)
func AddLinks(ctx context.Context, content string, links []string) (newContent string, err error)

func AddTags

func AddTags(ctx context.Context, content string, tags []string) (newContent string, err error)

TODO: Implement context handling.

func GetAddedBacklinks(old *domain.Document, new *domain.Document) (addedBacklinkIDs []int64, err error)
func GetAddedLinks(old *domain.Document, new *domain.Document) (addedLinkIDs []int64, err error)

func GetAddedTags

func GetAddedTags(old *domain.Document, new *domain.Document) (addedTagIDs []int64, err error)
func GetRemovedBacklinks(old *domain.Document, new *domain.Document) (removedBacklinkIDs []int64, err error)
func GetRemovedLinks(old *domain.Document, new *domain.Document) (removedLinkIDs []int64, err error)

func GetRemovedTags

func GetRemovedTags(old *domain.Document, new *domain.Document) (removedTagIDs []int64, err error)
func RemoveBacklinks(ctx context.Context, content string, links []string) (newContent string, err error)
func RemoveLinks(ctx context.Context, content string, links []string) (newContent string, err error)

func RemoveTags

func RemoveTags(ctx context.Context, content string, tags []string) (newContent string, err error)

Types

type BacklinksHeaderNotFoundError added in v0.6.0

type BacklinksHeaderNotFoundError struct {
	Inner error
}

func (BacklinksHeaderNotFoundError) As added in v0.6.0

func (err BacklinksHeaderNotFoundError) As(target any) bool

func (BacklinksHeaderNotFoundError) Error added in v0.6.0

func (BacklinksHeaderNotFoundError) Is added in v0.6.0

func (err BacklinksHeaderNotFoundError) Is(other error) bool

func (BacklinksHeaderNotFoundError) Unwrap added in v0.6.0

func (err BacklinksHeaderNotFoundError) Unwrap() error

type DocumentContentEntity added in v0.6.0

type DocumentContentEntity string
const (
	DocumentContentEntityTag      DocumentContentEntity = "tag"
	DocumentContentEntityLink     DocumentContentEntity = "link"
	DocumentContentEntityBacklink DocumentContentEntity = "backlink"
)

type DocumentContentManager

type DocumentContentManager struct {
	Repository repository.DocumentContentRepository
	Hooks      *bntp.Hooks[string]
	Logger     *log.Logger
}

func NewDocumentContentManager added in v0.6.0

func NewDocumentContentManager(logger *log.Logger, hooks *bntp.Hooks[string], repository repository.DocumentContentRepository) (DocumentContentManager, error)

func (*DocumentContentManager) Add

func (m *DocumentContentManager) Add(ctx context.Context, pathContents []tuple.T2[string, string]) error

TODO: Allow skipping certain hooks. TODO: Implement context handling.

func (m *DocumentContentManager) AddBackLinks(ctx context.Context, pathBacklinks []tuple.T2[string, []string]) error
func (m *DocumentContentManager) AddLinks(ctx context.Context, pathLinks []tuple.T2[string, []string]) error

func (*DocumentContentManager) AddTags

func (m *DocumentContentManager) AddTags(ctx context.Context, pathTags []tuple.T2[string, []string]) error

func (*DocumentContentManager) Delete

func (m *DocumentContentManager) Delete(ctx context.Context, paths []string) error

func (*DocumentContentManager) Get

func (m *DocumentContentManager) Get(ctx context.Context, paths []string) (contents []string, err error)

func (*DocumentContentManager) Move

func (m *DocumentContentManager) Move(ctx context.Context, pathChanges []tuple.T2[string, string]) error
func (m *DocumentContentManager) RemoveBackLinks(ctx context.Context, pathBacklinks []tuple.T2[string, []string]) error
func (m *DocumentContentManager) RemoveLinks(ctx context.Context, pathLinks []tuple.T2[string, []string]) error

func (*DocumentContentManager) RemoveTags

func (m *DocumentContentManager) RemoveTags(ctx context.Context, pathTags []tuple.T2[string, []string]) error

func (*DocumentContentManager) Update

func (m *DocumentContentManager) Update(ctx context.Context, pathContents []tuple.T2[string, string]) error

func (*DocumentContentManager) UpdateDocumentContentsFromFilterAndUpdater

func (m *DocumentContentManager) UpdateDocumentContentsFromFilterAndUpdater(ctx context.Context, filter *domain.DocumentFilter, updater *domain.DocumentUpdater, documentManager *DocumentManager) error

TODO: This mess needs a lot of cleaning up

func (*DocumentContentManager) UpdateDocumentContentsFromNewModels

func (m *DocumentContentManager) UpdateDocumentContentsFromNewModels(ctx context.Context, newDocuments []*domain.Document, documentManager *DocumentManager) error

type DocumentManager

type DocumentManager struct {
	Repository repository.DocumentRepository
	Hooks      *bntp.Hooks[domain.Document]
	Logger     *log.Logger
}

func NewDocumentManager

func NewDocumentManager(logger *log.Logger, hooks *bntp.Hooks[domain.Document], repository repository.DocumentRepository) (DocumentManager, error)

func (*DocumentManager) Add

func (m *DocumentManager) Add(ctx context.Context, documents []*domain.Document) error

TODO: Allow skipping certain hooks.

func (*DocumentManager) AddType

func (m *DocumentManager) AddType(ctx context.Context, types []string) error

func (*DocumentManager) CountAll

func (m *DocumentManager) CountAll(ctx context.Context) (numRecords int64, err error)

func (*DocumentManager) CountWhere

func (m *DocumentManager) CountWhere(ctx context.Context, documentFilter *domain.DocumentFilter) (numRecords int64, err error)

func (*DocumentManager) Delete

func (m *DocumentManager) Delete(ctx context.Context, documents []*domain.Document) error

func (*DocumentManager) DeleteType

func (m *DocumentManager) DeleteType(ctx context.Context, types []string) error

func (*DocumentManager) DeleteWhere

func (m *DocumentManager) DeleteWhere(ctx context.Context, documentFilter *domain.DocumentFilter) (numAffectedRecords int64, err error)

func (*DocumentManager) DoesExist

func (m *DocumentManager) DoesExist(ctx context.Context, document *domain.Document) (doesExist bool, err error)

func (*DocumentManager) DoesExistWhere

func (m *DocumentManager) DoesExistWhere(ctx context.Context, documentFilter *domain.DocumentFilter) (doesExist bool, err error)

func (*DocumentManager) GetAll

func (m *DocumentManager) GetAll(ctx context.Context) (records []*domain.Document, err error)

func (*DocumentManager) GetAllTypes added in v0.6.0

func (m *DocumentManager) GetAllTypes(ctx context.Context) ([]string, error)

func (*DocumentManager) GetFirstWhere

func (m *DocumentManager) GetFirstWhere(ctx context.Context, documentFilter *domain.DocumentFilter) (record *domain.Document, err error)

func (*DocumentManager) GetFromIDs added in v0.6.0

func (m *DocumentManager) GetFromIDs(ctx context.Context, ids []int64) (records []*domain.Document, err error)

func (*DocumentManager) GetWhere

func (m *DocumentManager) GetWhere(ctx context.Context, documentFilter *domain.DocumentFilter) (records []*domain.Document, err error)

func (*DocumentManager) Replace

func (m *DocumentManager) Replace(ctx context.Context, documents []*domain.Document) error

func (*DocumentManager) Update

func (m *DocumentManager) Update(ctx context.Context, documents []*domain.Document, documentUpdater *domain.DocumentUpdater) error

func (*DocumentManager) UpdateType

func (m *DocumentManager) UpdateType(ctx context.Context, oldType string, newType string) error

func (*DocumentManager) UpdateWhere

func (m *DocumentManager) UpdateWhere(ctx context.Context, documentFilter *domain.DocumentFilter, documentUpdater *domain.DocumentUpdater) (numAffectedRecords int64, err error)

func (*DocumentManager) Upsert

func (m *DocumentManager) Upsert(ctx context.Context, documents []*domain.Document) error

type DocumentSyntaxError added in v0.6.0

type DocumentSyntaxError struct {
	Inner error
}

func (DocumentSyntaxError) As added in v0.6.0

func (err DocumentSyntaxError) As(target any) bool

func (DocumentSyntaxError) Error added in v0.6.0

func (err DocumentSyntaxError) Error() string

func (DocumentSyntaxError) Is added in v0.6.0

func (err DocumentSyntaxError) Is(other error) bool

func (DocumentSyntaxError) Unwrap added in v0.6.0

func (err DocumentSyntaxError) Unwrap() error

type EmptyEntitiesListError added in v0.6.0

type EmptyEntitiesListError struct {
	Entity DocumentContentEntity
}

func (EmptyEntitiesListError) As added in v0.6.0

func (err EmptyEntitiesListError) As(target any) bool

func (EmptyEntitiesListError) Error added in v0.6.0

func (err EmptyEntitiesListError) Error() string

func (EmptyEntitiesListError) Is added in v0.6.0

func (err EmptyEntitiesListError) Is(other error) bool

type LinksHeaderNotFoundError added in v0.6.0

type LinksHeaderNotFoundError struct {
	Inner error
}

func (LinksHeaderNotFoundError) As added in v0.6.0

func (err LinksHeaderNotFoundError) As(target any) bool

func (LinksHeaderNotFoundError) Error added in v0.6.0

func (err LinksHeaderNotFoundError) Error() string

func (LinksHeaderNotFoundError) Is added in v0.6.0

func (err LinksHeaderNotFoundError) Is(other error) bool

func (LinksHeaderNotFoundError) Unwrap added in v0.6.0

func (err LinksHeaderNotFoundError) Unwrap() error

type TagsHeaderNotFoundError added in v0.6.0

type TagsHeaderNotFoundError struct {
	Inner error
}

func (TagsHeaderNotFoundError) As added in v0.6.0

func (err TagsHeaderNotFoundError) As(target any) bool

func (TagsHeaderNotFoundError) Error added in v0.6.0

func (err TagsHeaderNotFoundError) Error() string

func (TagsHeaderNotFoundError) Is added in v0.6.0

func (err TagsHeaderNotFoundError) Is(other error) bool

func (TagsHeaderNotFoundError) Unwrap added in v0.6.0

func (err TagsHeaderNotFoundError) Unwrap() error

Jump to

Keyboard shortcuts

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