Delete Time Series



Delete usage

Flow:

  • Open a session.
  • Create an instance of timeSeriesFor and pass it the following:
  • Call TimeSeriesFor.Delete:
    • Provide a single timestamp to delete a specific entry, or -
    • Specify a range of timestamps to delete multiple entries.
  • Call session.saveChanges for the action to take effect on the server.

Note:

  • If the specified document doesn't exist, a DocumentDoesNotExistException is thrown.
  • Attempting to delete nonexistent entries results in a no-op and generates no exception.
  • To delete the whole time series simply delete all its entries.
    The series is removed when all its entries are deleted.
  • Deleting a document deletes all its time series as well.

Examples

The following examples delete the time series entries that were appended in the Append article:

Delete single entry:


// Get an instance of 'timeSeriesFor'
const tsf = session.timeSeriesFor("users/john", "HeartRates");

// Call 'deleteAt' to delete a specific entry
timeStampOfEntry = new Date(baseTime.getTime() + 60_000);
tsf.deleteAt(timeStampOfEntry);

// Save changes
await session.saveChanges();

Delete range of entries:


// Get an instance of 'timeSeriesFor'
const tsf = session.timeSeriesFor("users/john", "HeartRates");

// Delete a range of 5 entries
FromTimeStamp = new Date(baseTime.getTime());
ToTimeStamp = new Date(baseTime.getTime() + 60_000 * 5);
tsf.delete(FromTimeStamp, ToTimeStamp);

// Save changes
await session.saveChanges();

Delete time series:


// Get an instance of 'timeSeriesFor'
const tsf = session.timeSeriesFor("users/john", "HeartRates");

// Delete ALL entries
// The whole time series will be removed
tsf.delete();

// Save changes
await session.saveChanges();

Syntax

// Available overloads:
// ====================

delete();          // Delete all entries
deleteAt(at);      // Delete a specific entry
delete(from, to);  // Delete a range of enties
Parameter Type Description
at Date Timestamp of the time series entry to delete.
from Date Delete the range of time series entries starting from this timestamp (inclusive).
Pass null to use the minimum date value.
to Date Delete the range of time series entries ending at this timestamp (inclusive).
Pass null to use the maximum date value.