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

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to Check if a Document Exists

In order to check if a document with specific ID exists in the database, use the Exists method from the Advanced session operations.


bool Exists(string id)
id string ID of the document to check the existence of.
Return Value
bool Indicates if a document with the given ID exists.


bool exists = session.Advanced.Exists("employees/1-A");
if (exists)
    //do something...