resolvers

package
v0.8.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 13 Imported by: 54

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 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, map[string]any{"test": 123})
provider := search.NewProvider(resolver)
...

func NewRecordFieldResolver

func NewRecordFieldResolver(
	dao *daos.Dao,
	baseCollection *models.Collection,
	requestData *models.FilterRequestData,
	allowHiddenFields bool,
) *RecordFieldResolver

NewRecordFieldResolver creates and initializes a new `RecordFieldResolver`.

@todo consider changing in v0.8+:

  • requestData to a typed struct when introducing the "IN" operator
  • allowHiddenFields -> isSystemAdmin

func (*RecordFieldResolver) Resolve

func (r *RecordFieldResolver) Resolve(fieldName string) (resultName string, placeholderParams dbx.Params, err error)

Resolve implements `search.FieldResolver` interface.

Example of resolvable field formats:

id
project.screen.status
@request.status
@request.auth.someRelation.name
@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