Class AbstractManager<T, S, ModelType>Abstract

class: AbstractManager

  • abstract model manager to cover all models which extend CoreModel.
  • feature to handle 'name' like unique value in same type.
  • typed-storage based.

Abstract

Type Parameters

Hierarchy

Constructors

  • default constructor

    Type Parameters

    Parameters

    • type: ModelType

      model type string

    • parent: S

      service instance which implements StorageMakeable interface

    • fields: string[]

      list of model field names

    • Optional uniqueField: string

      (optional) unique field name

    • Optional ns: string

      (optional) namespace to be printed. pass NULL to suppress all logs. global NS value will be used if not specified or undefined.

    Returns AbstractManager<T, S, ModelType>

Properties

$unique: UniqueFieldManager<T, ModelType>
FIELDS: string[]
NS: string
parent: S
storage: TypedStorageService<T, ModelType>

Accessors

Methods

  • Private

    internal implementation for 'update' and 'updateOrCreate'

    Parameters

    • id: string

      model id

    • model: T

      model object

    • Optional $inc: T

      (optional) incremental set

    • isCreate: boolean = true

      (optional) flag to allow creating a new model (default: true)

    Returns Promise<T>

  • default implementation of deleting model

    Parameters

    • id: string

      model id

    • destroy: boolean = true

      flag for hard delete or soft delete (by setting 'deletedAt' field)

    Returns Promise<T>

  • callback invoked just before the model is saved

    • override this to customize default behavior to perform model validation, cleansing or normalization

    Parameters

    • model: T

      model object

    • Optional origin: T

      original model currently in the storage

    Returns T

  • default implementation of 'preparing' model

    • prepare model w/ safe creation

    Parameters

    • id: string

      model-id to prepare

    • Optional $def: T

      default model value

    • isCreate: boolean = true

      (optional) flag to allow creating a new model (default: true)

    Returns Promise<T>

  • prepare default model when creation

    • sub classes should implement this method

    Abstract

    Parameters

    • $def: T

      default model

    Returns T

  • default implementation of updating model

    Parameters

    • id: string

      model id

    • model: T

      model object

    • Optional $inc: T

      (optional) incremental set

    Returns Promise<T>

  • default implementation of 'upserting' model

    Parameters

    • id: string

      model id

    • model: T

      model object

    • Optional $inc: T

      (optional) incremental set

    Returns Promise<T>

Generated using TypeDoc