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.


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


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