Class Controller

Controller

A controller class for handling database queries using Objection.js models.

Constructors

  • Parameters

    • SqliteModel: typeof Model

      The Objection.js model.

    • options: {
          searchIn?: string[];
      } = {}

      Additional options for the controller.

      • OptionalsearchIn?: string[]

        Columns to search in by default.

    Returns Controller

Properties

Model: typeof Model
qcolumns: undefined | string[]

Methods

  • Deletes records by ID(s).

    Parameters

    • param0: IIds

      The ID or IDs of records to delete.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.

  • Deletes records based on where clause.

    Parameters

    • whereData: WhereMethod<any>

      Criteria for delete operation.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.

  • Formats an error response object.

    Parameters

    • OptionalerrorObj: any

      The error object or message.

    • Optionalstatus: number = 500

      The HTTP status code.

    • Optionalcode: number = 0

      Additional status code.

    Returns IStatusCode

    The error response object.

  • Finds string type columns in the model's JSON schema.

    Parameters

    • ModelIn: typeof Model = ...

      The model to inspect. Defaults to this.Model.

    Returns string[]

    A list of string type column names.

  • Inserts one or multiple records.

    Parameters

    • data: object | object[]

      The data to insert.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.

  • Lists records based on search criteria.

    Parameters

    • dataSearch: ISearch

      The search criteria.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.

  • Selects a record by its ID.

    Parameters

    • param0: IIds

      The ID or IDs to select.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.

  • Selects one record based on given criteria without considering active state.

    Parameters

    • find: object

      Criteria to find the record.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.

  • Selects one active record based on given criteria.

    Parameters

    • find: object

      Criteria to find the record.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.

  • Formats a successful response object.

    Parameters

    • Optionaldata: any

      The data to return in the response.

    • Optionalstatus: number = 200

      The HTTP status code.

    • Optionalcode: number = 0

      Additional status code.

    Returns IStatusCode

    The success response object.

  • Merges additional data into a successful response object.

    Parameters

    • Optionaldata: any

      The data to return in the response.

    • Optionalstatus: number = 200

      The HTTP status code.

    • Optionalcode: number = 0

      Additional status code.

    Returns IStatusCode

    The merged success response object.

  • Updates records using an upsert operation.

    Parameters

    • data: object | object[]

      The data for upsert.

    • OptionalqueryBuilder: any

      Optional query builder instance.

    Returns Promise<IStatusCode>

    The promise of the resulting data.