docfilter

package
v0.0.0-...-bd94320 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentsFilter

type DocumentsFilter struct {
	// contains filtered or unexported fields
}

DocumentsFilter used to filter metadata by given filters.

If no filters are provided, all metadata will be returned. Filters can be added with AddFilter function.

FilterData function returns filtered metadata.

Must be initialized with New function.

func New

func New(limit, offset int) *DocumentsFilter

New creates new DocumentsFilter instance.

limit and offset are used to limit and offset returned metadata.

Returns *DocumentsFilter.

func (*DocumentsFilter) AddFilter

func (f *DocumentsFilter) AddFilter(key, value string) error

AddFilter adds a new filter to the DocumentsFilter based on the provided key and value.

key specifies the type of filter to apply and must be one of the predefined filter keys. value is used to configure the filter and should match the expected format for the specified key.

All filters must be added before calling FilterData.

you can find all available filter keys and their corresponding values in the filters package.

Returns an error if the key is unknown or the value is invalid for the specified filter.

func (DocumentsFilter) FilterData

func (f DocumentsFilter) FilterData(data []models.Metadata) []models.Metadata

FilterData filters the given slice of metadata according to the filters set in the DocumentsFilter and returns a new slice of filtered metadata.

The function will return up to `limit` number of metadata items that match all the filters. The `offset` is used to skip the first `offset` matching metadata.

The method will return an empty slice if no metadata match the filters or if the `limit` is set to 0.

The function will not modify the original slice.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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