You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to Check if an Attachment Exists

  • To check whether a document contains a certain attachment, use the method exists() from the session.advanced().attachments() operations.

  • This does not load the document or the attachment from the server, and it does not cause the session to track the document.

  • In this page:


boolean exists(String documentId, String name);
Parameter Type Description
documentId String The ID of the document you want to check for the attachment
name String The name of the attachment you want to check the document for
Return Value Description
boolean Indicates if a document with the specified ID exists in the database


boolean exists = session

if (exists) {
    // do something