Partager via


IVectorStoreRecordCollection<TKey,TRecord>.UpsertAsync Method

Definition

Upserts a record into the vector store. Does not guarantee that the collection exists. If the record already exists, it will be updated. If the record does not exist, it will be created.

public System.Threading.Tasks.Task<TKey> UpsertAsync (TRecord record, Microsoft.SemanticKernel.Data.UpsertRecordOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UpsertAsync : 'Record * Microsoft.SemanticKernel.Data.UpsertRecordOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Key>
Public Function UpsertAsync (record As TRecord, Optional options As UpsertRecordOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TKey)

Parameters

record
TRecord

The record to upsert.

options
UpsertRecordOptions

Optional options for upserting the record.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task<TKey>

The unique identifier for the record.

Exceptions

Throw when the command fails to execute for any reason.

Throw when mapping between the storage model and record data model fails.

Applies to