How to Check if a Document Exists
-
To check whether the database contains a certain document,
use thesession.advanced
operationsexists
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
def exists(self, key: str) -> bool: ...
Parameter | Type | Description |
---|---|---|
key | str |
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 |