You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: Deleting entities

Entities can be marked for deletion by using delete method, but will not be removed from server until save_changes is called.

Syntax

def delete(self, key_or_entity):

def delete_by_entity(self, entity):
Parameters
entity or key_or_entity entity, str or entity instance of entity to delete or entity Id
expected_change_vector str A change vector to use for concurrency checks

The delete method can be used with entity or str. by calling delete with entity delete_by_entity will be executed

Example 1

employee = session.load("employees/1")
session.delete(employee)
session.save_changes()

Example 2

session.delete("employees/1")

Example 3

employee = session.load("employees/1")
session.delete_by_entity(employee)