Query InfluxDB. Provides methods that notify about result lines of the executed query. See https://docs.influxdata.com/influxdb/latest/api/#operation/PostQuery

interface QueryApi {
    collectLines(query: string | ParameterizedQuery): Promise<string[]>;
    collectRows<T>(
        query: string | ParameterizedQuery,
        rowMapper?: (
            values: string[],
            tableMeta: FluxTableMetaData,
        ) => undefined | T,
    ): Promise<T[]>;
    iterateLines(query: string | ParameterizedQuery): AsyncIterable<string>;
    iterateRows(query: string | ParameterizedQuery): AsyncIterable<Row>;
    lines(query: string | ParameterizedQuery): Observable<string>;
    queryLines(
        query: string | ParameterizedQuery,
        consumer: CommunicationObserver<string>,
    ): void;
    queryRaw(query: string | ParameterizedQuery): Promise<string>;
    queryRows(
        query: string | ParameterizedQuery,
        consumer: FluxResultObserver<string[]>,
    ): void;
    response(query: string | ParameterizedQuery): AnnotatedCSVResponse;
    rows(query: string | ParameterizedQuery): Observable<Row>;
    with(options: Partial<QueryOptions>): QueryApi;
}

Methods

  • CollectLines executes the query and collects all result lines in the returned Promise. This method is suitable to collect simple results. Use with caution, a possibly huge stream of lines is copied to memory.

    Parameters

    Returns Promise<string[]>

    Promise of returned csv lines

  • CollectRows executes the query and collects all the results in the returned Promise. This method is suitable to collect simple results. Use with caution, a possibly huge stream of results is copied to memory.

    Type Parameters

    • T

    Parameters

    • query: string | ParameterizedQuery

      query

    • OptionalrowMapper: (values: string[], tableMeta: FluxTableMetaData) => undefined | T

      maps the supplied row to an item that is then collected, undefined return values are not collected. If no rowMapper is supplied, row => tableMeta.toObject(row.values) is used.

    Returns Promise<T[]>

    Promise of mapped results

  • IterateLines executes the supplied query and returns results in an async iterable of annotated CSV lines. Async iterables are best consumed by for-await loop.

    Parameters

    Returns AsyncIterable<string>

    async iterable of CSV result lines

  • IterateRows executes the supplied query and returns results in an async iterable of row data and table metadata pairs. Async iterables are best consumed by for-await loop.

    Parameters

    Returns AsyncIterable<Row>

    async iterable of CSV result lines

MMNEPVFCICPMFPCPTTAAATR