Skip to content

Commit

Permalink
feat: skip route key for AddOrUpdateManyAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-aelf committed Sep 3, 2024
1 parent 2935bf8 commit 25bd865
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ await client.IndexAsync(model, ss => ss.Index(indexName).Refresh(_elasticsearchO
}

public async Task AddOrUpdateManyAsync(List<TEntity> list, string collectionName = null,
CancellationToken cancellationToken = default)
CancellationToken cancellationToken = default, bool skipRouteKey = false)
{
string entityName = typeof(TEntity).Name;
_logger.LogDebug("[{1}]Before AddOrUpdateManyAsync time: {0} ",
Expand All @@ -161,7 +161,7 @@ public async Task AddOrUpdateManyAsync(List<TEntity> list, string collectionName
var isSharding = _shardingKeyProvider.IsShardingCollection();

var client = await GetElasticsearchClientAsync(cancellationToken);
if (!isSharding)
if (!isSharding || skipRouteKey)
{
await BulkAddAsync(client, indexNames, list, isSharding, cancellationToken);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface IEntityMappingBasicRepository<TEntity, TKey> where TEntity : cl

Task AddOrUpdateAsync(TEntity model, string collectionName = null, CancellationToken cancellationToken = default);

Task AddOrUpdateManyAsync(List<TEntity> list, string collectionName = null, CancellationToken cancellationToken = default);
Task AddOrUpdateManyAsync(List<TEntity> list, string collectionName = null, CancellationToken cancellationToken = default, bool skipRouteKey = false);

Task UpdateAsync(TEntity model, string collectionName = null, CancellationToken cancellationToken = default);

Expand Down

0 comments on commit 25bd865

Please sign in to comment.