You are currently browsing legacy 4.1 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: 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.

Syntax

boolean exists(String id)

Parameters
id String ID of the document to check the existence of.
Return Value
boolean Indicates if a document with the given ID exists.

Example

boolean exists = session.advanced().exists("employees/1-A");
if (exists) {
    // do something ...
}