resolvers

package
v0.0.0-...-5919eae Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package resolvers contains custom search.FieldResolver implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionsFinder

type CollectionsFinder interface {
	FindCollectionByNameOrId(collectionNameOrId string) (*models.Collection, error)
}

CollectionsFinder defines a common interface for retrieving collections and other related models.

The interface at the moment is primarily used to avoid circular dependency with the daos.Dao package.

type RecordFieldResolver

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

RecordFieldResolver defines a custom search resolver struct for managing Record model search fields.

Usually used together with `search.Provider`. Example:

resolver := resolvers.NewRecordFieldResolver(
    app.Dao(),
    myCollection,
    &models.RequestInfo{...},
    true,
)
provider := search.NewProvider(resolver)
...

func NewRecordFieldResolver

func NewRecordFieldResolver(
	dao CollectionsFinder,
	baseCollection *models.Collection,
	requestInfo *models.RequestInfo,

	allowHiddenFields bool,
) *RecordFieldResolver

NewRecordFieldResolver creates and initializes a new `RecordFieldResolver`.

func (*RecordFieldResolver) Resolve

func (r *RecordFieldResolver) Resolve(fieldName string) (*search.ResolverResult, error)

Resolve implements `search.FieldResolver` interface.

Example of some resolvable fieldName formats:

id
someSelect.each
project.screen.status
screen.project_via_prototype.name
@request.context
@request.method
@request.query.filter
@request.headers.x_token
@request.auth.someRelation.name
@request.data.someRelation.name
@request.data.someField
@request.data.someSelect:each
@request.data.someField:isset
@collection.product.name

func (*RecordFieldResolver) UpdateQuery

func (r *RecordFieldResolver) UpdateQuery(query *dbx.SelectQuery) error

UpdateQuery implements `search.FieldResolver` interface.

Conditionally updates the provided search query based on the resolved fields (eg. dynamically joining relations).

Jump to

Keyboard shortcuts

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