Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Query

Class for creating and then managing a sequential query.

Hierarchy

  • Query

Index

Constructors

constructor

  • new Query(connection: Connection, statement: QuerySelect, preselect: boolean, queryId: number): Query
  • Creates a select query for one or more tables of an API connection.

    Parameters

    • connection: Connection

      The API connection.

    • statement: QuerySelect
    • preselect: boolean
    • queryId: number

    Returns Query

Accessors

id

  • get id(): number
  • Returns number

index

Methods

back

  • back(rows: number): Promise<void>
  • Reposition the query backward with a number of records.

    Parameters

    • rows: number

    Returns Promise<void>

close

  • close(): Promise<void>
  • Closes the query, no other operation is possible afterwards.

    It is recommended to close a query when not needed anymore to free-up resources on the 4GL agent. Otherwise the resources used by the query will hang up until the connection is closed.

    Returns Promise<void>

count

  • count(): Promise<number>
  • Returns the number of rows in the query.

    Returns Promise<number>

delete

  • delete(): Promise<void>
  • Deletes the current record in the query.

    Returns Promise<void>

deleteAll

  • deleteAll(): Promise<number>
  • Deletes all records in the query, when resolved it returns the number of records deleted.

    Returns Promise<number>

each

  • each(callback: function): Promise<void>
  • Asynchronously executes a callback function for each record of the query. The callback function receives the query record as first parameter and optionally the query index.

    Regardless of the current query index the query starts from the first record and at the end the query index is always on the last record.

    Parameters

    • callback: function

      The callback function to be executed for each record in query.

        • Parameters

          Returns void

    Returns Promise<void>

fields

  • Returns the table(s) fields in the query.

    Returns Promise<IQueryFields>

first

  • Retrieves the first record from the query.

    Returns Promise<QueryRecord>

forward

  • forward(rows: number): Promise<void>
  • Reposition the query forward with a number of records.

    Parameters

    • rows: number

    Returns Promise<void>

get

  • Retrieve a record from the query, reposition as needed. If reposition is not specified it returns the current record if available or fetchs the first one otherwise.

    Parameters

    Returns Promise<QueryRecord>

last

  • Retrieves the last record from the query.

    Returns Promise<QueryRecord>

next

  • Retrieves the next record from the query.

    Returns Promise<QueryRecord>

previous

  • Retrieves the previous record from the query.

    Returns Promise<QueryRecord>

reposition

  • reposition(index: number): Promise<void>
  • Reposition the query to a specific index - this is either a number (zero base) or 'last', 'first'.

    Parameters

    • index: number

    Returns Promise<void>