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:


// Delete a single entry
using (var session = store.OpenSession())
{
    session.TimeSeriesFor("users/john", "HeartRates")
        .Delete(baseline.AddMinutes(1));

    session.SaveChanges();
}

Delete range of entries:


// Delete a range of entries from the time series
using (var session = store.OpenSession())
{
    session.TimeSeriesFor("users/john", "HeartRates")
        .Delete(baseline.AddSeconds(0), baseline.AddSeconds(9));

    session.SaveChanges();
}

Syntax

// Delete a single time-series entry
void Delete(DateTime at);

// Delete a range of time-series entries
void Delete(DateTime? from = null, DateTime? to = null);
Parameter Type Description
at DateTime Timestamp of the time series entry to delete.
from DateTime? Delete the range of time series entries starting from this timestamp (inclusive).
Default: DateTime.MinValue
to DateTime? Delete the range of time series entries ending at this timestamp (inclusive).
Default: DateTime.MaxValue