Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction :

A time series  is a series of numerical values ​​representing the evolution of a specific quantity over time. this API allows easy management of these data.

Usage :

To use the spinalTimeSeries API, you must :

  • Install :


Code Block
languagebash
titleInstallation
npm install --save https://github.com/spinalcom/spinal-models-timeSeries.git

...

Code Block
titleImport and Instantiate
var TimeSeries = require("spinal-models-timeSeries").TimeSeries; // import

var timeSeries = new TimeSeries(); // instantiate

Methods :

new TimeSeries()

takes as parameter a number (data to save ) and saves an object of type {date: saveDate, value: dataToSave} in timeSeries data.

ParamTypeDescriptionMandatory
ValuenumberValue To save yes

Not Takes a param and returns an object that contains the date and value of current timeSeries.

Takes as parameters two dates (in millisecond or a date string in a valid format, preferably "year-month-day hours:minutes:seconds" for example : 2018-10-25 16:26:30 ) and returns a Array of all timeSeries between the two dates.

It returns an array of all timeSeries between argBeginDate and argEndDate

ParamTypeDescriptionMandatory
argBeginDateDateMust be a date in milisecond or in year-month-day hours:minutes:seconds formyes
argEndDateDatethe last date in milisecond or in year-month-day hours:minutes:seconds formatNo

It Takes a date as params and return the data corresponding to this date, it returns an empty object if no data is associated with the date.

returns an object that contains the date and data corresponding to argDate.

ParamTypeDescriptionMandatory
argDateDateMust be a date in milisecond or in year-month-day hours:minutes:seconds formatyes

It takes a date as a params and remove and returns the data corresponding to this date. It returns the data corresponding to this date, returns undefined if no data found. 

ParamTypeDescriptionMandatory
dateToRemoveDateMust be a date in milisecond or in year-month-day hours:minutes:seconds formatyes

this function takes as parameters two date (one optional), if both dates are given it archives all date between both (they even included) else it archives the date given.

ParamTypeDescriptionMandatory
beginDateDateMust be a date in milisecond or in year-month-day hours:minutes:seconds formatyes
[endDate]DateOptional, must be a date in milisecond or in year-month-day hours:minutes:seconds formatNo

this function allows to get all data archived, it returns a Promise.

this function allows to archive the data of the timeSeries, by changing the attribute archiveTime you change the archiving frequency.