Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShortID<InputType, OutputType, FormatParams>

Type parameters

  • InputType

  • OutputType

  • FormatParams

Hierarchy

Index

Constructors

constructor

  • new ShortID(app: App, collection: Collection, name: string, required: boolean, display_hints: any): ShortID
  • Creates a new instance of a field

    Parameters

    • app: App
    • collection: Collection
    • name: string
    • required: boolean
    • display_hints: any

    Returns ShortID

Properties

collection

collection: Collection

The collection this field is attached to

display_hints

display_hints: any

The display hints specified for this field

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

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

Methods

decode

  • Reverse to the Field.encode function. Takes what's inside the database and returns the value in a given format

    Parameters

    Returns Promise<OutputType | null>

encode

  • encode(_: any, input: string | null): Promise<string>
  • Parameters

    • _: any
    • input: string | null

    Returns Promise<string>

filterToQuery

  • filterToQuery(context: Context, filter: any): Promise<any>
  • Generates a mongo query based on the filter value

    Parameters

    Returns 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

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
  • Returns boolean

init

  • init(_: App): Promise<void>
  • Runs when the app is being started. Hooks can be set up within this function

    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(): Promise<{ reason?: undefined | string; valid: boolean }>
  • Returns Promise<{ reason?: undefined | string; valid: boolean }>

setParams

  • setParams(_: any): void
  • This method is used to set and process the params upon the field's creation when the app starts up. The type of argument of this method determines type checking that's performed by @{link FieldDefinitionHelper}.

    Parameters

    • _: any

    Returns void

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