Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClassSchema<T>

Type parameters

  • T

Hierarchy

  • ClassSchema

Index

Constructors

constructor

  • new ClassSchema(classType: ClassType<any>): ClassSchema
  • Parameters

    • classType: ClassType<any>

    Returns ClassSchema

Properties

classProperties

classProperties: Map<string, PropertySchema> = new Map<string, PropertySchema>()

classType

classType: ClassType<T>

Optional collectionName

collectionName: undefined | string

Optional databaseName

databaseName: undefined | string

Optional decorator

decorator: undefined | string

Name of the property which this class is decorating. As soon as someone use this class, the actual value of this property is used to serialize.

Optional discriminant

discriminant: undefined | string

Name of the property that is a discriminant of this class. This is automatically set when at least one property has @f.discriminant.

Protected hasDefaultsInitialized

hasDefaultsInitialized: boolean = false

Protected hasFullLoadHooksCheck

hasFullLoadHooksCheck: boolean = false

Optional idField

idField: keyof T & string

indices

indices: EntityIndex[] = []

Protected initializedMethods

initializedMethods: {}
internal

Type declaration

  • [name: string]: true

Protected methodProperties

methodProperties: Map<string, PropertySchema[]> = new Map<string, PropertySchema[]>()

Each method can have its own PropertySchema definition for each argument, where map key = method name.

methods

methods: {}

Type declaration

Protected methodsParamNames

methodsParamNames: Map<string, string[]> = new Map<string, string[]>()

Protected methodsParamNamesAutoResolved

methodsParamNamesAutoResolved: Map<string, string[]> = new Map<string, string[]>()

Optional name

name: undefined | string

onLoad

onLoad: { methodName: string; options: { fullLoad?: undefined | false | true } }[] = []

propertyNames

propertyNames: string[] = []

Protected referenceInitialized

referenceInitialized: boolean = false

references

references: Set<PropertySchema> = new Set<PropertySchema>()

Contains all references, owning reference and back references.

Methods

addIndex

  • Parameters

    Returns void

addProperty

  • Adds dynamically new properties to the class schema definition. Use the f decorator as you already do at the class directly.

    Note: Once a transform method is called like plainToClass/classToPlain etc this method has no effect since compiler templates are then already built. So make sure to call this addProperty() before calling transform methods.

    example
    const schema = getClassSchema(MyClass);
    //or
    const schema = createClassSchema(MyClass);
    
    schema.addProperty('anotherOne', f.type(String));

    Parameters

    Returns void

clone

  • Parameters

    • classType: ClassType<any>

    Returns ClassSchema

findReverseReference

  • All references have a counter-part. This methods finds it and errors if not possible.

    If the given reference is a owning reference it finds the correct backReference, which can be found by checking all reference options.mappedBy.

    If the given reference is a back reference it finds the owning reference, which can be found by using its options.mappedBy.

    Alternatively we simply check for resolvedClassType to be given classType, and if only one found, we return it. When more than one found, we throw an error saying the user he should make its relation mapping not ambiguous.

    Parameters

    Returns PropertySchema

getClassName

  • getClassName(): string
  • Returns string

getClassProperties

  • Returns Map<string, PropertySchema>

getDecoratedPropertySchema

  • Returns PropertySchema

getDiscriminantPropertySchema

  • Returns PropertySchema

getIndex

  • Parameters

    • name: string

    Returns EntityIndex | undefined

getMethod

  • Parameters

    • name: string

    Returns PropertySchema

getMethodProperties

  • Returns all annotated arguments as PropertSchema for given method name.

    Parameters

    • name: string

    Returns PropertySchema[]

getMethodsParamNames

  • getMethodsParamNames(methodName: string): string[]
  • internal

    Parameters

    • methodName: string

    Returns string[]

getMethodsParamNamesAutoResolved

  • getMethodsParamNamesAutoResolved(methodName: string): string[]
  • internal

    Parameters

    • methodName: string

    Returns string[]

getOrCreateMethodProperties

  • internal

    Parameters

    • name: string

    Returns PropertySchema[]

getPrimaryField

  • Internal note: for multi pk support, this will return a PropertySchema[] in the future.

    Returns PropertySchema

getPrimaryFieldRepresentation

  • getPrimaryFieldRepresentation(item: T): any
  • Returns a perfect hash from the primary key(s).

    Parameters

    • item: T

    Returns any

getPropertiesByGroup

  • Parameters

    • Rest ...groupNames: string[]

    Returns PropertySchema[]

getProperty

  • Parameters

    • name: string

    Returns PropertySchema

getPropertyOrUndefined

  • Parameters

    • name: string

    Returns PropertySchema | undefined

hasFullLoadHooks

  • hasFullLoadHooks(): boolean
  • Returns boolean

hasMethod

  • hasMethod(name: string): boolean
  • Returns true if the method got a @f decorator.

    Parameters

    • name: string

    Returns boolean

hasProperty

  • hasProperty(name: string): boolean
  • Parameters

    • name: string

    Returns boolean

Protected initializeMethod

  • initializeMethod(name: string): void
  • Parameters

    • name: string

    Returns void

initializeProperties

  • initializeProperties(): void
  • Before accessing classProperties, its necessary to call this method.

    Returns void

loadDefaults

  • loadDefaults(): void
  • Returns void

registerReference

  • Parameters

    Returns void

resetInitialized

  • resetInitialized(): void
  • Returns void

Generated using TypeDoc