Class: DatumLoader

DatumLoader

Load data for a set of source IDs, date range, and aggregate level using the listDatumUrl() endpoint of NodeDatumUrlHelperMixin.

This object is designed to be used once per query. After creating the object and configuring an asynchronous callback function with DatumLoader#callback, call DatumLoader#load to startloading the data. The callback function will be called once all data has been loaded. The callback function can also be passed as an argument to the DatumLoader#load method directly.


new DatumLoader(urlHelper, filter [, authBuilder])

Constructor.

Parameters:
Name Type Argument Description
urlHelper NodeDatumUrlHelperMixin

a URL helper for accessing node datum via SolarQuery

filter DatumFilter

the filter parameters to use

authBuilder AuthorizationV2Builder <optional>

the auth builder to authenticate requests with; if not provided then only public data can be queried; when provided a pre-signed key must be available

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

const urlHelper = new NodeDatumUrlHelper();

new DatumLoader(urlHelper, filter).load((error, results) => {
  // results is an array of Datum objects
});

Members


<static, readonly> version :string

The class version.

Type:
  • string

filter :DatumFilter

Type:
  • DatumFilter

urlHelper :NodeDatumUrlHelper

Type:
  • NodeDatumUrlHelper

Methods


callback( [value])

Get or set the callback function, invoked after all data has been loaded. The callback function will be passed two arguments: an error and the results. In incremental mode, the callback will also be passed a boolean that will be true on that last page of data, and a Pagination that details which page the callback represents.

Parameters:
Name Type Argument Description
value DatumLoader~dataCallback <optional>

the callback function to use

Returns:

when used as a getter, the current callback function, otherwise this object

Type
DatumLoader~dataCallback | DatumLoader

incremental( [value])

Get or set incremental mode for loading the data.

When incremental mode is enabled (set to true) then the callback function will be invoked for each result page that is loaded. 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:
Name Type Argument Description
value boolean <optional>

the incremental mode to set

Returns:

when used a a getter, the incremental mode; otherwise this object

Type
boolean | DatumLoader

load( [callback])

Initiate loading the data.

As an alternative to configuring the callback function via the DatumLoader#callback method,a callback function can be passed as an argument to this function. That allows this function to be passed to things like queue.defer, for example.

Parameters:
Name Type Argument Description
callback DatumLoader~dataCallback <optional>

a callback function to use; either this argument must be provided or the function must have already been configured via DatumLoader#callback

Implements:
Returns:

this object

Type
DatumLoader

parameters( [value])

Get or 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:
Name Type Argument Description
value object <optional>

the URL parameters to include with the JSON request

Returns:

when used as a getter, the URL parameters, otherwise this object

Type
object | DatumLoader

Type Definitions


dataCallback( [error], data [, done] [, page])

The data callback function.

Parameters:
Name Type Argument Description
error Error <optional>

an error if a failure occurred

data Array.<Datum>

the result data

done boolean <optional>

in incremental mode, will be true when invoked on the last page of data

page Pagination <optional>

in incremental mode, the page associated with the data