Skip to main content

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.

  • Calling 'Exists' does not Load the document entity to the session,
    and the session will not track it.

  • In this page:

Check if document exists

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

if (exists)
{
// document 'employees/1-A exists
}

Syntax

bool Exists(string id);
ParameterTypeDescription
idstringThe ID of the document to check
Return ValueDescription
booltrue - the document exists in the database.
false - The document does Not exist in the database