Session: How to Check if a Document Exists
Syntax
bool Exists(string id);
Task<bool> ExistsAsync(string documentId, CancellationToken token = default);
Parameter | Type | Description |
---|---|---|
id | string |
The ID of the document you want to check the database for |
Return Value | Description |
---|---|
bool |
Indicates whether a document with the specified ID exists in the database |
Example
bool exists = session.Advanced.Exists("employees/1-A");
if (exists)
{
//do something
}
bool exists = await asyncSession.Advanced.ExistsAsync("employees/1-A");
if (exists)
{
//do something
}