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
trueon that last page of data, and aPaginationthat details which page the callback represents.Parameters:
Name Type Argument Description valueDatumLoader~dataCallback <optional>
the callback function to use
Returns:
when used as a getter, the current callback function, otherwise this object
-
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 secondbooleanargument that will be set totrueonly 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 valueboolean <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#callbackmethod,a callback function can be passed as an argument to this function. That allows this function to be passed to things likequeue.defer, for example.Parameters:
Name Type Argument Description callbackDatumLoader~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 valueobject <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 errorError <optional>
an error if a failure occurred
dataArray.<Datum> the result data
doneboolean <optional>
in incremental mode, will be
truewhen invoked on the last page of datapagePagination <optional>
in incremental mode, the page associated with the data