Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IORMAdapter

An ORM Adapter defines how Pwoli should interact between that ORM for which that ORMAdapter is implemented.

Every ORM Adapter created for Pwoli must implement this interface as these are the set of properties and methods required for Pwoli's DB related operations.

author

Mahesh S Warrier https://github.com/codespede

Hierarchy

Implemented by

Index

Properties

initialization: Promise<void>

A Promise which resolves when this Component has been successfully initialized.

modelClass: Model

The base Model class of the ORM.

validatorMap: {}

This is the object which is used to map the validators in the ORM with the client side validators in Pwoli. Keys of this object are the validator strings for the ORM and the values are the corresponding validators in Pwoli. This is used by assets/js/activeForm.js

Type declaration

  • [key: string]: string

Methods

  • activeAttributes(model: Model): string[]
  • applyPagination(query: {}, pagination: any): {}
  • This method applies the current request's pagination requirements. This is used by ActiveDataProvider.

    Parameters

    • query: {}

      The DB query used.

      • [key: string]: any
    • pagination: any

    Returns {}

    The query object after pagination is applied.

    • [key: string]: any
  • applySort(query: {}, sort: Sort): {}
  • This method applies the current request's sort requirements. This is used by ActiveDataProvider.

    Parameters

    • query: {}

      The DB query used.

      • [key: string]: any
    • sort: Sort

      The Sort object being used.

    Returns {}

    The query object after sorting is applied.

    • [key: string]: any
  • attributes(): string[]
  • count<T>(query: T): Promise<number>
  • Returns the count of records based on the query provided.

    Type parameters

    • T: {}

    Parameters

    • query: T

      The DB query,

    Returns Promise<number>

    A Promise which resolves to the number of records found.

  • findAll(query: {}): Promise<Model[]>
  • getActiveValidators(model: Model, attribute: string): {}[]
  • Returns the active validators for the given attribute in the given Model.

    Parameters

    • model: Model

      The Model to be checked.

    • attribute: string

      The attribute to be checked.

    Returns {}[]

  • getClientValidationParams(criteria: boolean | {}): {}
  • Returns the params required for Client Validation

    Parameters

    • criteria: boolean | {}

      Either false(meaning no validation to be performed) or an object which contains the message' and args` for client validation done by assets/js/activeForm.js Eg:- { msg: 'Invalid value', args: {...}} For more information on this, please refer ActiveField.clientValidators

    Returns {}

    • [key: string]: any
  • init(): Promise<void>
  • Initializes the object. This method is invoked at the end of the constructor after the object is initialized with the given configuration.

    Returns Promise<void>

  • isAttributeActive(model: Model, attribute: string): boolean
  • Checks whether the given attribute is an active attribute in the given Model. Active attributes are attributes for which at-least a single validation rule is applied.

    Parameters

    • model: Model

      The Model in which the check is to be performed.

    • attribute: string

      The attribute to be checked.

    Returns boolean

  • isAttributeRequired(model: Model, attribute: string): boolean
  • Checks whether a given attribute is required for a Model

    Parameters

    • model: Model

      The Model in which the check is to be performed.

    • attribute: string

      The attribute to be checked.

    Returns boolean

  • primaryKey(): string
  • Sets attributes to the Model provided

    Parameters

    • model: Model

      The Model to which attributes are to be set.

    • values: {}

      An object containing the attributes and values to be set. Eg:- { name: 'Mahesh', gender: 'Male' }

      • [key: string]: any

    Returns Model

    The Model itself after the attributes are set.

  • This method validates the given Model with the validation rules set inside it. The results of the validation will be stored in [Model._errors]. If this is an empty array, it can be considered that the validation has passed.

    Parameters

    • model: Model

      The Model in which validation is to be performed.

    Returns Promise<Model>

Generated using TypeDoc