Delete Time Series
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
and provide the timestamps range of the entries you want to delete. - Call
session.SaveChanges
for the action to take effect on the server.
Note:
- If the specified document doesn't exist, a
DocumentDoesNotExistException
will be thrown. - Attempting to delete nonexistent entries results in a no-op and generates no exception.
- To delete a 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.
Example
In the following example we delete a time series entry appended by sample code in the
append article.
// Delete a single entry
$session = $store->openSession();
try {
$session->timeSeriesFor("users/john", "HeartRates")
->delete((clone $baseTime)->add(new DateInterval("PT1M")));
$session->saveChanges();
} finally {
$session->close();
}