You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 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

  • To check whether the database contains a certain document, use the method exists() from the advanced session operations.

  • This does not load the document from the server or cause the session to track it.

  • In this page:


boolean exists(String id);
Parameter Type Description
id String The ID of the document you want to check the database for
Return Value Description
boolean Indicates whether a document with the specified ID exists in the database


boolean exists = session.advanced().exists("employees/1-A");

if (exists) {
    // do something