Cancellation Tokens for Text Index and GetIndex

This commit is contained in:
Sean Garrett
2023-06-24 12:41:17 +01:00
parent b7b23e7b92
commit aaf80a7ae2
5 changed files with 535 additions and 190 deletions
@@ -1,16 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository
{
/// <summary>
/// The interface exposing index management functionality for Guid Keyed repositories.
/// The interface exposing index management functionality for Guid Keyed repositories.
/// </summary>
public interface IBaseMongoRepository_Index : IBaseMongoRepository_Index<Guid>
{
/// <summary>
/// Returns the names of the indexes present on a collection.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>()
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Returns the names of the indexes present on a collection.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Returns the names of the indexes present on a collection.
/// </summary>
@@ -18,13 +40,110 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="partitionKey">An optional partition key</param>
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey = null)
Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Returns the names of the indexes present on a collection.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="partitionKey">An optional partition key</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
@@ -33,13 +152,29 @@ namespace MongoDbGenericRepository
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
@@ -54,7 +189,7 @@ namespace MongoDbGenericRepository
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
@@ -69,7 +204,7 @@ namespace MongoDbGenericRepository
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
@@ -84,7 +219,7 @@ namespace MongoDbGenericRepository
/// <summary>
/// Creates a combined text index.
/// IndexCreationOptions can be supplied to further specify
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>