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

const exists = await session.advanced.exists("employees/1-A");
if (exists) {
    // document 'employees/1-A exists


Parameter Type Description
id string The ID of the document to check
Return Value Description
Promise<boolean> true - the document exists in the database.
false - The document does Not exist in the database