Class AzureCosmosDBServiceBase
- Namespace
- FoundationaLLM.Context.Services.CosmosDB
- Assembly
- FoundationaLLM.ContextEngine.dll
Provides the base implementation for the Azure Cosmos DB services.
public class AzureCosmosDBServiceBase : IAzureCosmosDBServiceBase
- Inheritance
-
AzureCosmosDBServiceBase
- Implements
- Inherited Members
- Extension Methods
Constructors
AzureCosmosDBServiceBase(IOptions<AzureCosmosDBSettings>, ILogger<AzureCosmosDBServiceBase>)
Initializes a new instance of the AzureCosmosDBServiceBase class.
public AzureCosmosDBServiceBase(IOptions<AzureCosmosDBSettings> options, ILogger<AzureCosmosDBServiceBase> logger)
Parameters
optionsIOptions<AzureCosmosDBSettings>The IOptions providing the AzureCosmosDBSettings) with the Azure Cosmos DB settings.
loggerILogger<AzureCosmosDBServiceBase>The ILogger used for logging.
Fields
_contextContainer
protected readonly Container _contextContainer
Field Value
_cosmosClient
protected readonly CosmosClient _cosmosClient
Field Value
_logger
protected readonly ILogger<AzureCosmosDBServiceBase> _logger
Field Value
_settings
protected readonly AzureCosmosDBSettings _settings
Field Value
Properties
ContextContainer
Gets the context container for the Azure Cosmos DB service.
public Container ContextContainer { get; }
Property Value
Methods
ItemExists<T>(string, string, Func<T, bool>?)
Determines whether an item with the specified partition key and identifier exists in the data store.
public Task<bool> ItemExists<T>(string partitionKey, string id, Func<T, bool>? existencePredicate)
Parameters
partitionKeystringThe partition key that identifies the logical partition containing the item. Cannot be null or empty.
idstringThe unique identifier of the item within the specified partition. Cannot be null or empty.
existencePredicateFunc<T, bool>An optional predicate function to further validate the existence of the item based on its properties.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result is true if the item exists; otherwise, false.
Type Parameters
TThe type of the item to check for existence.
RetrieveItems<T>(QueryDefinition)
Retrieves items from Azure Cosmos DB.
public Task<List<T>> RetrieveItems<T>(QueryDefinition query)
Parameters
queryQueryDefinitionThe query definition used to retrieve the items.
Returns
Type Parameters
TThe type of item to retrieve.
UpsertItemAsync<T>(string, T, CancellationToken)
Upserts an item in Azure Cosmos DB.
public Task<T> UpsertItemAsync<T>(string partitionKey, T item, CancellationToken cancellationToken = default)
Parameters
partitionKeystringThe partition of the item to upsert.
itemTThe item to upsert.
cancellationTokenCancellationTokenThe cancellation token used to signal a cancellation request.
Returns
- Task<T>
The upserted item.
Type Parameters
TThe type of the item to upsert.