Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CachedValue<T, FormatParams>

Type parameters

Hierarchy

Index

Constructors

constructor

Properties

app

app: App

collection

collection: Collection

The collection this field is attached to

display_hints

display_hints: any

The display hints specified for this field

get_value

get_value: GetValue<T>

handles_large_data

handles_large_data: boolean = false

Whether or not the field handles large data

todo:

see if there's any viability in storing this

name

name: string

the name of the field

refresh_on

refresh_on: RefreshCondition[]

required

required: boolean

Whether or not this field should always have a value. Creating a resource with a value missing for a required field will throw an error

value_path_after_field_name

value_path_after_field_name: ".value"

virtual_field

virtual_field: T

Methods

checkForPossibleRecursiveEdits

  • checkForPossibleRecursiveEdits(): void
  • Returns void

decode

  • decode(context: Context, decoded_value: Depromisify<ReturnType<this["encode"]>>, old_value: Parameters<T["decode"]>[2], format: Parameters<T["decode"]>[3]): Promise<any>
  • Parameters

    • context: Context
    • decoded_value: Depromisify<ReturnType<this["encode"]>>
    • old_value: Parameters<T["decode"]>[2]
    • format: Parameters<T["decode"]>[3]

    Returns Promise<any>

encode

  • encode(context: Context, value: Parameters<T["encode"]>[1], old_value?: Parameters<T["encode"]>[2]): Promise<any>
  • Parameters

    • context: Context
    • value: Parameters<T["encode"]>[1]
    • Optional old_value: Parameters<T["encode"]>[2]

    Returns Promise<any>

filterToQuery

  • filterToQuery(context: Context, filter: any): Promise<any>

fullTextSearchEnabled

  • fullTextSearchEnabled(): Promise<boolean>
  • Whether or not the db should create a fulltext index on this field

    Returns Promise<boolean>

getAggregationStages

  • getAggregationStages(context: Context, query_params: { filter?: undefined | {} }): Promise<QueryStage[]>
  • Creates parts of a Mongo Pipieline that will be used to filter the items when listing items of a collection

    Parameters

    • context: Context
    • query_params: { filter?: undefined | {} }
      • Optional filter?: undefined | {}

    Returns Promise<QueryStage[]>

getAttachmentLoader

  • getAttachmentLoader(context: Context, omit_it: Boolean, attachment_params: ConstructorParameters<typeof ReferenceToCollection>[2]): AttachmentLoader | null
  • If the field supports attachments, it should return a properly configured AttachmentLoader. Not necessary for most basic fields.

    Parameters

    • context: Context
    • omit_it: Boolean
    • attachment_params: ConstructorParameters<typeof ReferenceToCollection>[2]

    Returns AttachmentLoader | null

getDefaultValue

getSpecification

  • getSpecification(): { display_hints: any; name: string; type: string }
  • Return a summary of this field

    Returns { display_hints: any; name: string; type: string }

    • display_hints: any
    • name: string
    • type: string

getTypeName

  • getTypeName(): string
  • Returns string

getValuePath

  • getValuePath(): Promise<string>
  • Value path is where inside a single record should the DB look for the field's value when filtering resources. Some fields use complex objects for storage and overwrite this method, and thanks to that they don't have to reimplement Field.getAggregationStages

    Returns Promise<string>

hasDefaultValue

  • hasDefaultValue(): boolean
  • Whether or not a field has a default value - that is, a value given to the field if no value is provided

    Returns boolean

hasIndex

  • hasIndex(): boolean | "text" | {}
  • Whether or not this field should have a dedicated index in the database

    Returns boolean | "text" | {}

init

  • init(app: App): Promise<void>
  • Parameters

    Returns Promise<void>

isOldValueSensitive

  • Whether or not any of the methods of the field depend on the previous value of the field

    Parameters

    Returns boolean

isProperValue

  • isProperValue(context: Context, new_value: Parameters<T["isProperValue"]>[1], old_value: Parameters<T["isProperValue"]>[2]): Promise<{ reason?: undefined | string; valid: boolean }>
  • Parameters

    • context: Context
    • new_value: Parameters<T["isProperValue"]>[1]
    • old_value: Parameters<T["isProperValue"]>[2]

    Returns Promise<{ reason?: undefined | string; valid: boolean }>

Private refresh_outdated_cache_values

  • Parameters

    Returns Promise<void>

setParams

Static fromDefinition

  • fromDefinition<T>(app: App, collection: Collection, definition: { display_hints?: any; name: string; params?: Parameters<InstanceType<FieldClass>["setParams"]>[0]; required?: undefined | false | true; type: T }): Field<any, any, any>
  • Create a new instance of Field based on the definition. **It's recommended to use FieldDefinitionHelper instead

    Type parameters

    Parameters

    • app: App
    • collection: Collection
    • definition: { display_hints?: any; name: string; params?: Parameters<InstanceType<FieldClass>["setParams"]>[0]; required?: undefined | false | true; type: T }
      • Optional display_hints?: any
      • name: string
      • Optional params?: Parameters<InstanceType<FieldClass>["setParams"]>[0]
      • Optional required?: undefined | false | true
      • type: T

    Returns Field<any, any, any>

Static invalid

Static valid

Generated using TypeDoc