Delete Time Series
-
Use
TimeSeriesFor.Delete
for the following actions:- Delete a single time series entry
- Delete a range of entries
- Delete the whole time series:
To remove the whole time series simply delete all its entries.
-
In this page:
Delete
usage
Flow:
- Open a session.
-
Create an instance of
TimeSeriesFor
and pass it the following:- Provide an explicit document ID, or -
pass an entity tracked by the session, e.g. a document object returned from session.Query or from session.Load. - Specify the time series name.
- Provide an explicit document ID, or -
-
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
In the following examples we delete time series entries appended by sample code 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 a time series entry to delete. |
from | DateTime? |
Delete the time series entries range that starts at this timestamp (inclusive). Default: DateTime.MinValue |
to | DateTime? |
Delete the time series entries range that ends at this timestamp (inclusive). Default: DateTime.MaxValue |