Get Time Series Operation



Get entries - from single time series


Example

In this example, we retrieve all entries from a single time series.

// Define the get operation
var getTimeSeriesOp = new GetTimeSeriesOperation(
    "employees/1-A",  // The document ID    
    "HeartRates");    // The time series name

// Execute the operation by passing it to 'operations.send'
const timeSeriesEntries = await documentStore.operations.send(getTimeSeriesOp);

// Access entries
const firstEntryReturned = timeSeriesEntries.entries[0];

Syntax

// Available overloads:
// ====================
const getTimeSeriesOp = new GetTimeSeriesOperation(docId, timeseries);
const getTimeSeriesOp = new GetTimeSeriesOperation(docId, timeseries, from, to);
const getTimeSeriesOp = new GetTimeSeriesOperation(docId, timeseries, from, to, start);
const getTimeSeriesOp = new GetTimeSeriesOperation(docId, timeseries, from, to, start, pageSize);
Parameter Type Description
docId string Document ID
timeseries string Time series name
from Date Get time series entries starting from this timestamp (inclusive).
Default: The minimum date value will be used.
to Date Get time series entries ending at this timestamp (inclusive).
Default: The maximum date value will be used.
start number The position of the first result to retrieve (for paging).
Default: 0
pageSize number Number of results per page to retrieve (for paging).
Default: 2,147,483,647 (equivalent to int.MaxValue in C#).

Return Value:

class TimeSeriesRangeResult {
    // Timestamp of first entry returned
    from; // Date;

    // Timestamp of last entry returned
    to; // Date;

    // The resulting entries
    // Will be empty if requesting an entries range that does Not exist
    entries; // TimeSeriesEntry[];
    
    // The number of entries returned
    // Will be undefined if not all entries of this time series were returned
    totalResults; // number
}

  • Details of class TimeSeriesEntry are listed in this syntax section.
  • If the requested time series does Not exist, a null object will be returned.
  • No exceptions are generated.

Get entries - from multiple time series


Example

In this example, we retrieve entries from the specified ranges of two time series.

const baseTime = new Date();

const startTime1 = new Date(baseTime.getTime() + 60_000 * 5);
const endTime1 = new Date(baseTime.getTime() + 60_000 * 10);

const startTime2 = new Date(baseTime.getTime() + 60_000 * 15);
const endTime2 = new Date(baseTime.getTime() + 60_000 * 20);

// Define the get operation
const getMultipleTimeSeriesOp = new GetMultipleTimeSeriesOperation(
    "employees/1-A",
    [
        {
            name: "ExerciseHeartRates",
            from: startTime1,
            to: endTime1
        },
        {
            name: "RestHeartRates",
            from: startTime2,
            to: endTime2
        }
    ]));

// Execute the operation by passing it to 'operations.send'
const timesSeriesEntries = await documentStore.operations.send(getMultipleTimeSeriesOp);

// Access entries
const timeSeriesEntry = timesSeriesEntries.values.get("ExerciseHeartRates")[0].entries[0];

Syntax

// Available overloads:
// ====================
const getMultipleTimeSeriesOp = new GetMultipleTimeSeriesOperation(docId, ranges);
const getMultipleTimeSeriesOp = new GetMultipleTimeSeriesOperation(docId, ranges, start, pageSize);
Parameter Type Description
docId string Document ID
ranges TimeSeriesRange[] Provide a TimeSeriesRange object for each time series from which you want to retrieve data
start number The position of the first result to retrieve (for paging)
Default: 0
pageSize number Number of results per page to retrieve (for paging)
Default: Default: 2,147,483,647 (equivalent to int.MaxValue in C#).

// The TimeSeriesRange object:
// ===========================
{
    // Name of time series
    name, // string
    
    // Get time series entries starting from this timestamp (inclusive).    
    from, // Date

    // Get time series entries ending at this timestamp (inclusive).
    to  // Date
}

Return Value:

class TimeSeriesDetails {
    // The document ID
    id; // string
    
    // Dictionary of time series name to the time series results 
    values; // Map<string, TimeSeriesRangeResult[]>
}

class TimeSeriesRangeResult {
    // Timestamp of first entry returned
    from; // Date;

    // Timestamp of last entry returned
    to; // Date;

    // The resulting entries
    // Will be empty if requesting an entries range that does Not exist
    entries; // TimeSeriesEntry[];
    
    // The number of entries returned
    // Will be undefined if not all entries of this time series were returned
    totalResults; // number
}
  • If any of the requested time series do not exist, the returned object will be null.

  • When an entries range that does not exist are requested,
    the return value for the that range is a TimeSeriesRangeResult object with an empty entries property.

  • No exceptions are generated.