using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using MongoDbGenericRepository.DataAccess.Base;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository.DataAccess.Index
{
///
/// The MongoDbIndexHandler interface. used to create indexes on collections.
///
public interface IMongoDbIndexHandler : IDataAccessBase
{
///
/// Returns the names of the indexes present on a collection.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// An optional partition key
/// An optional Cancellation Token.
/// A list containing the names of the indexes on on the concerned collection.
Task> GetIndexesNamesAsync(string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The field we want to index.
/// Options for creating an index.
/// An optional partition key.
/// An optional cancellation token
/// The result of the create index operation.
Task CreateTextIndexAsync(
Expression> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The field we want to index.
/// Options for creating an index.
/// An optional partition key.
/// An optional cancellation token.
/// The result of the create index operation.
Task CreateAscendingIndexAsync(
Expression> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The field we want to index.
/// Options for creating an index.
/// An optional partition key.
/// An optional cancellation token.
/// The result of the create index operation.
Task CreateDescendingIndexAsync(
Expression> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The field we want to index.
/// Options for creating an index.
/// An optional partition key.
/// An optional cancellation token.
/// The result of the create index operation.
Task CreateHashedIndexAsync(
Expression> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Creates a combined text index.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The fields we want to index.
/// Options for creating an index.
/// An optional partition key.
/// An optional Cancellation token.
/// The result of the create index operation.
Task CreateCombinedTextIndexAsync(
IEnumerable>> fields,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Drops the index given a field name
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The name of the index
/// An optional partition key
/// An optional cancellation token,
Task DropIndexAsync(string indexName, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
}
}