Cancellation Tokens for Text Index and GetIndex
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
using CoreUnitTests.Infrastructure;
|
||||||
|
|
||||||
|
namespace CoreUnitTests.KeyTypedRepositoryTests.IndexTests;
|
||||||
|
|
||||||
|
public class GetIndexNamesAsyncTests : TestKeyedMongoRepositoryContext<int>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
|
|
||||||
namespace MongoDbGenericRepository
|
namespace MongoDbGenericRepository
|
||||||
@@ -36,93 +37,195 @@ namespace MongoDbGenericRepository
|
|||||||
set { _mongoDbIndexHandler = value; }
|
set { _mongoDbIndexHandler = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Returns the names of the indexes present on a collection.
|
public async Task<List<string>> GetIndexesNamesAsync<TDocument>()
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing 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>
|
|
||||||
public async Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey = null)
|
|
||||||
where TDocument : IDocument<Guid>
|
where TDocument : IDocument<Guid>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, Guid>(partitionKey);
|
return await GetIndexesNamesAsync<TDocument, Guid>(null, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the names of the indexes present on a collection.
|
/// <inheritdoc />
|
||||||
/// </summary>
|
public async Task<List<string>> GetIndexesNamesAsync<TDocument>(CancellationToken cancellationToken)
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
where TDocument : IDocument<Guid>
|
||||||
/// <typeparam name="TKey">The type for the key of the document.</typeparam>
|
{
|
||||||
/// <param name="partitionKey">An optional partition key</param>
|
return await GetIndexesNamesAsync<TDocument, Guid>(null, cancellationToken);
|
||||||
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
|
}
|
||||||
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey = null)
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await GetIndexesNamesAsync<TDocument, Guid>(partitionKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await GetIndexesNamesAsync<TDocument, Guid>(partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>()
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, TKey>(partitionKey);
|
return await GetIndexesNamesAsync<TDocument, TKey>(null, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Create a text index on the given field.
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(CancellationToken cancellationToken)
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
|
||||||
/// how the creation should be done.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing 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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
|
||||||
where TDocument : IDocument<Guid>
|
|
||||||
{
|
|
||||||
return await MongoDbIndexHandler.CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await GetIndexesNamesAsync<TDocument, TKey>(null, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates an index on the given field in ascending order.
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey)
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
where TDocument : IDocument<TKey>
|
||||||
/// how the creation should be done.
|
where TKey : IEquatable<TKey>
|
||||||
/// </summary>
|
{
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
return await GetIndexesNamesAsync<TDocument, TKey>(partitionKey, CancellationToken.None);
|
||||||
/// <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>
|
/// <inheritdoc />
|
||||||
/// <returns>The result of the create index operation.</returns>
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, TKey>(partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, null, null, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, null, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, null, partitionKey, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, null, partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<Guid>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, TKey>(field, null, null, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, TKey>(field, null, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, TKey>(field, null, partitionKey, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, TKey>(field, null, partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await MongoDbIndexHandler.CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<Guid>
|
where TDocument : IDocument<Guid>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
return await CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates an index on the given field in ascending order.
|
|
||||||
/// 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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
@@ -130,20 +233,11 @@ namespace MongoDbGenericRepository
|
|||||||
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates an index on the given field in descending order.
|
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
|
||||||
/// how the creation should be done.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing 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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<Guid>
|
where TDocument : IDocument<Guid>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
return await CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -154,20 +248,11 @@ namespace MongoDbGenericRepository
|
|||||||
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates a hashed 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>
|
|
||||||
/// <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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<Guid>
|
where TDocument : IDocument<Guid>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -178,20 +263,11 @@ namespace MongoDbGenericRepository
|
|||||||
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates a combined text index.
|
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
|
||||||
/// how the creation should be done.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
||||||
/// <param name="fields">The fields we want to index.</param>
|
|
||||||
/// <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>
|
|
||||||
public async Task<string> CreateCombinedTextIndexAsync<TDocument>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public async Task<string> CreateCombinedTextIndexAsync<TDocument>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<Guid>
|
where TDocument : IDocument<Guid>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateCombinedTextIndexAsync<TDocument, Guid>(fields, indexCreationOptions, partitionKey);
|
return await CreateCombinedTextIndexAsync<TDocument, Guid>(fields, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -202,16 +278,11 @@ namespace MongoDbGenericRepository
|
|||||||
return await MongoDbIndexHandler.CreateCombinedTextIndexAsync<TDocument, TKey>(fields, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateCombinedTextIndexAsync<TDocument, TKey>(fields, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Drops the index given a field name
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
||||||
/// <param name="indexName">The name of the index</param>
|
|
||||||
/// <param name="partitionKey">An optional partition key</param>
|
|
||||||
public async Task DropIndexAsync<TDocument>(string indexName, string partitionKey = null)
|
public async Task DropIndexAsync<TDocument>(string indexName, string partitionKey = null)
|
||||||
where TDocument : IDocument<Guid>
|
where TDocument : IDocument<Guid>
|
||||||
{
|
{
|
||||||
await MongoDbIndexHandler.DropIndexAsync<TDocument, Guid>(indexName, partitionKey);
|
await DropIndexAsync<TDocument, Guid>(indexName, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
|
|
||||||
@@ -11,6 +12,27 @@ namespace MongoDbGenericRepository
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBaseMongoRepository_Index : IBaseMongoRepository_Index<Guid>
|
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>
|
/// <summary>
|
||||||
/// Returns the names of the indexes present on a collection.
|
/// Returns the names of the indexes present on a collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -18,7 +40,104 @@ namespace MongoDbGenericRepository
|
|||||||
/// <typeparam name="TKey">The type of the primary key for 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="partitionKey">An optional partition key</param>
|
||||||
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
|
/// <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
|
||||||
|
/// 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 TDocument : IDocument<TKey>
|
||||||
where TKey : IEquatable<TKey>;
|
where TKey : IEquatable<TKey>;
|
||||||
|
|
||||||
@@ -33,7 +152,23 @@ namespace MongoDbGenericRepository
|
|||||||
/// <param name="indexCreationOptions">Options for creating an index.</param>
|
/// <param name="indexCreationOptions">Options for creating an index.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The result of the create index operation.</returns>
|
/// <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 TDocument : IDocument<TKey>
|
||||||
where TKey : IEquatable<TKey>;
|
where TKey : IEquatable<TKey>;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CancellationToken = System.Threading.CancellationToken;
|
||||||
|
|
||||||
namespace MongoDbGenericRepository
|
namespace MongoDbGenericRepository
|
||||||
{
|
{
|
||||||
@@ -38,104 +39,119 @@ namespace MongoDbGenericRepository
|
|||||||
set { _mongoDbIndexHandler = value; }
|
set { _mongoDbIndexHandler = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Returns the names of the indexes present on a collection.
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument>()
|
||||||
/// </summary>
|
where TDocument : IDocument<TKey>
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
{
|
||||||
/// <param name="partitionKey">An optional partition key</param>
|
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, TKey>();
|
||||||
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
|
}
|
||||||
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey = null)
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument>(CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, TKey>(cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey)
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, TKey>(partitionKey);
|
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, TKey>(partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Create a text index on the given field.
|
public virtual async Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey, CancellationToken cancellationToken)
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
|
||||||
/// how the creation should be done.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing 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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.GetIndexesNamesAsync<TDocument, TKey>(partitionKey, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates an index on the given field in ascending order.
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
where TDocument : IDocument<TKey>
|
||||||
/// how the creation should be done.
|
{
|
||||||
/// </summary>
|
return await CreateTextIndexAsync(field, null, null, CancellationToken.None);
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
}
|
||||||
/// <param name="field">The field we want to index.</param>
|
|
||||||
/// <param name="indexCreationOptions">Options for creating an index.</param>
|
/// <inheritdoc />
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||||
/// <returns>The result of the create index operation.</returns>
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync(field, null, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync(field, indexCreationOptions, null, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync(field, indexCreationOptions, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync(field, null, partitionKey, CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await CreateTextIndexAsync(field, null, partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
{
|
||||||
|
return await MongoDbIndexHandler.CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates an index on the given field in descending order.
|
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
|
||||||
/// how the creation should be done.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing 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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates a hashed 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>
|
|
||||||
/// <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>
|
|
||||||
/// <returns>The result of the create index operation.</returns>
|
|
||||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates a combined text index.
|
|
||||||
/// IndexCreationOptions can be supplied to further specify
|
|
||||||
/// how the creation should be done.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
||||||
/// <param name="fields">The fields we want to index.</param>
|
|
||||||
/// <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>
|
|
||||||
public virtual async Task<string> CreateCombinedTextIndexAsync<TDocument>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
public virtual async Task<string> CreateCombinedTextIndexAsync<TDocument>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
{
|
{
|
||||||
return await MongoDbIndexHandler.CreateCombinedTextIndexAsync<TDocument, TKey>(fields, indexCreationOptions, partitionKey);
|
return await MongoDbIndexHandler.CreateCombinedTextIndexAsync<TDocument, TKey>(fields, indexCreationOptions, partitionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Drops the index given a field name
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
||||||
/// <param name="indexName">The name of the index</param>
|
|
||||||
/// <param name="partitionKey">An optional partition key</param>
|
|
||||||
public virtual async Task DropIndexAsync<TDocument>(string indexName, string partitionKey = null)
|
public virtual async Task DropIndexAsync<TDocument>(string indexName, string partitionKey = null)
|
||||||
where TDocument : IDocument<TKey>
|
where TDocument : IDocument<TKey>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
|
|
||||||
@@ -12,13 +13,113 @@ namespace MongoDbGenericRepository
|
|||||||
/// <typeparam name="TKey"></typeparam>
|
/// <typeparam name="TKey"></typeparam>
|
||||||
public interface IBaseMongoRepository_Index<TKey> where TKey : IEquatable<TKey>
|
public interface IBaseMongoRepository_Index<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>
|
||||||
|
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
|
||||||
|
Task<List<string>> GetIndexesNamesAsync<TDocument>()
|
||||||
|
where TDocument : IDocument<TKey>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the names of the indexes present on a collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing 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>(CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<TKey>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the names of the indexes present on a collection.
|
/// Returns the names of the indexes present on a collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="partitionKey">An optional partition key</param>
|
/// <param name="partitionKey">An optional partition key</param>
|
||||||
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
|
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
|
||||||
Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey = null)
|
Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the names of the indexes present on a collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing 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>(string partitionKey, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<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>
|
||||||
|
/// <param name="field">The field we want to index.</param>
|
||||||
|
/// <returns>The result of the create index operation.</returns>
|
||||||
|
Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
|
||||||
|
where TDocument : IDocument<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>
|
||||||
|
/// <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>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<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>
|
||||||
|
/// <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>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||||
|
where TDocument : IDocument<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>
|
||||||
|
/// <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>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||||
|
where TDocument : IDocument<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>
|
||||||
|
/// <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>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||||
|
where TDocument : IDocument<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>
|
||||||
|
/// <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>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||||
where TDocument : IDocument<TKey>;
|
where TDocument : IDocument<TKey>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,7 +132,21 @@ namespace MongoDbGenericRepository
|
|||||||
/// <param name="indexCreationOptions">Options for creating an index.</param>
|
/// <param name="indexCreationOptions">Options for creating an index.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The result of the create index operation.</returns>
|
/// <returns>The result of the create index operation.</returns>
|
||||||
Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||||
|
where TDocument : IDocument<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>
|
||||||
|
/// <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>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||||
where TDocument : IDocument<TKey>;
|
where TDocument : IDocument<TKey>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user