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:


Syntax

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

Example

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

if (exists) {
    // do something
}