Table of Contents

Interface IAzureCosmosDBServiceBase

Namespace
FoundationaLLM.Context.Interfaces
Assembly
FoundationaLLM.ContextEngine.dll

Defines the interface for the Azure Cosmos DB service that provides core database services.

public interface IAzureCosmosDBServiceBase
Extension Methods

Properties

ContextContainer

Gets the context container for the Azure Cosmos DB service.

Container ContextContainer { get; }

Property Value

Container

Methods

ItemExists<T>(string, string, Func<T, bool>?)

Determines whether an item with the specified partition key and identifier exists in the data store.

Task<bool> ItemExists<T>(string partitionKey, string id, Func<T, bool>? existencePredicate)

Parameters

partitionKey string

The partition key that identifies the logical partition containing the item. Cannot be null or empty.

id string

The unique identifier of the item within the specified partition. Cannot be null or empty.

existencePredicate Func<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

T

The type of the item to check for existence.

RetrieveItems<T>(QueryDefinition)

Retrieves items from Azure Cosmos DB.

Task<List<T>> RetrieveItems<T>(QueryDefinition query)

Parameters

query QueryDefinition

The query definition used to retrieve the items.

Returns

Task<List<T>>

The list of retrieved items.

Type Parameters

T

The type of item to retrieve.

UpsertItemAsync<T>(string, T, CancellationToken)

Upserts an item in Azure Cosmos DB.

Task<T> UpsertItemAsync<T>(string partitionKey, T item, CancellationToken cancellationToken = default)

Parameters

partitionKey string

The partition of the item to upsert.

item T

The item to upsert.

cancellationToken CancellationToken

The cancellation token used to signal a cancellation request.

Returns

Task<T>

The upserted item.

Type Parameters

T

The type of the item to upsert.