solarnetwork-api-core
    Preparing search index...

    Class DatumLoader

    Load data for a set of source IDs, date range, and aggregate level using either the listDatumUrl() or datumReadingUrl() URLs of SolarQueryApi (the /datum/list or /datum/reading endpoints).

    This object is designed to be used once per query. After creating the object and optionally configuring any other settings, call Tool.DatumLoader#fetch to start loading the data. The returned Promise will be resolved once all data has been loaded.

    const filter = new DatumFilter();
    filter.nodeId = 123;
    // configure other filter settings here...

    const results = await new DatumLoader(new SolarQueryApi(), filter).fetch();
    // results is an array of Datum objects

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    The URL helper instance to use.

    An authorization builder to use to make authenticated HTTP requests.

    filter: DatumFilter

    The filter.

    Methods

    • Get the concurrency limit to use for parallel requests.

      Returns number

      the current concurrency value

    • Set the concurrency limit to use for parallel requests.

      By default requests are not made in parallel (this property is configured as 0). Change to a positive number to enable parallel query mode.

      When parallel mode is enabled the loader will make one request that includes the total result count and first page of results, followed by parallel requests for any remaining pages based on that total result count and configured page size.

      Parameters

      • value: number

        the concurrency level to use, or Infinity for no limit

      Returns this

      this object

    • Get the flag for requesting the total results count.

      By default the datum loader will not request the overal total result count when querying for data, as this speeds up queries. By setting this to true the total result count will be requested on the first query page.

      Returns boolean

      the total results count inclusion mode

    • Set the flag for requesting the total results count.

      By default the datum loader will not request the overal total result count when querying for data, as this speeds up queries. By setting this to true the total result count will be requested on the first query page.

      Parameters

      • value: boolean

        the flag to include total results count

      Returns this

      this object

    • Get the incremental mode for loading the data.

      Returns boolean

      true if incremental mode is enabled

    • Set incremental mode for loading the data.

      When incremental mode is enabled (set to true) then the callback function will be invoked after each result page that is loaded, passing all results loaded thusfar. The function will be passed a second boolean argument that will be set to true only on the last page of result data, and a third Pagination` object argument that details the starting offset of the page.

      When incremental mode is disabled (set to false, the default) then all result pages are combined into a single array and the callback will be invoked just once.

      Parameters

      • value: boolean

        true to enable incremental mode

      Returns this

      this object

    • Get the concurrency jitter value to use for parallel requests.

      Returns number

      the current concurrency jitter value (milliseconds); defaults to 150

    • Set the concurrency jitter amount to use for parallel requests.

      When parallel mode is enabled by setting concurrency() to a positive value, a random amount of "pause" time can be added before parallel requests are made by configuring this to a positive value. This can be helpful to avoid API rate limiting errors.

      Parameters

      • value: number

        the concurrency jitter amount to use, in milliseconds, or 0 to disable

      Returns this

      this object

    • Get the result pagination size.

      Returns number

      the pagination size; defaults to 1000

    • Set the result pagination size.

      Parameters

      • value: number

        the pagination size to set

      Returns this

      this object

    • Get the additional URL parameters.

      Returns null | object

      the URL parameters, or null

    • Set additional URL parameters.

      The parameters are set as object properties. If a property value is an array, multiple parameters for that property will be added.

      Parameters

      • value: null | object

        the URL parameters to include with the JSON request, or null to remove any existing parameters object

      Returns this

      this object

    • Get the URL to a proxy to use for loading the data.

      Returns null | string

      the proxy URL

    • Set the URL to a proxy to use for loading the data.

      This can be configured as an absolute URL to the proxy server to use instead of making requests directly to the URL returned by the configured SolarQueryApi. For example:

      Parameters

      • value: null | string

        the proxy URL to set, or null or an empty string to not use any proxy

      Returns this

      this object

    • Get the readings mode for loading the data.

      Returns boolean

      true to return reading query, false for list query

    • Set the readings mode for loading the data.

      When readings mode is enabled (set to true) then the /datum/reading endpoint will be invoked to load data.

      When readings mode is disabled (set to false, the default) then the /datum/list endpoint will be invoked to load data.

      Parameters

      • value: boolean

        true to return reading query, false for list query

      Returns this

      this object

    • Create a URL fetch requestor.

      The returned function can be passed to d3.queue or invoked directly.

      Type Parameters

      • V

      Parameters

      • url: string

        the URL to request.

      • OptionalsignUrl: string

        the URL to sign (might be different to url if a proxy is used)

      • Optionaldelay: number

        an optional number of milliseconds to sleep before initiating the request

      Returns (cb: LoaderDataCallbackFn<V>) => void

      a function that accepts a callback argument