How to Check if a Document Exists


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

  • 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

$exists = $session->advanced()->exists("employees/1-A");

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

Syntax

public function exists(?string $id): bool;
Parameter Type Description
$id ?string The ID of the document to look for
Return Value Description
bool true - this document exists in the database.
false - The document does Not exist in the database