using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; using MongoDB.Driver; using MongoDB.Driver.Linq; using MongoDbGenericRepository.DataAccess.Base; using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository.DataAccess.Index { 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 /// A list containing the names of the indexes on on the concerned collection. Task> GetIndexesNamesAsync(string partitionKey = null) 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. /// The result of the create index operation. Task CreateTextIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) 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. /// The result of the create index operation. Task CreateAscendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) 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. /// The result of the create index operation. Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) 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. /// The result of the create index operation. Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) 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. /// The result of the create index operation. Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) 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 Task DropIndexAsync(string indexName, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a IMongoQueryable for a potentially partitioned document type and a filter. /// /// The document type. /// The type of the primary key. /// The filter definition. /// The collection partition key. /// IMongoQueryable GetQuery(Expression> filter, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a collections for a potentially partitioned document type. /// /// The document type. /// The type of the primary key. /// The document. /// IMongoCollection HandlePartitioned(TDocument document) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a collections for a potentially partitioned document type. /// /// The document type. /// The type of the primary key. /// The collection partition key. /// IMongoCollection HandlePartitioned(string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a collections for the type TDocument with a partition key. /// /// The document type. /// The type of the primary key. /// The collection partition key. /// IMongoCollection GetCollection(string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; } }