From ffc7e65b7b91a78912b7f4a95862c1d977d9819a Mon Sep 17 00:00:00 2001 From: Alexandre SPIESER Date: Sun, 7 Oct 2018 19:46:34 +0100 Subject: [PATCH] Update README.md --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 751b5c0..517aa1f 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,40 @@ It is now possible to change the collection name by using the `CollectionName` a ``` Documents of this type will be inserted into a collection named "MyCollectionName". +## Index Management +From version 1.3.8 the `MongoDbGenericRepository` implements the `IMongoDbCollectionIndexRepository` interface. +This exposes the functionality to programmatically manage indexes against your collections in a generic fashion. + +The following methods are exposed and fully integration tested: ++ CreateAscendingIndexAsync ++ CreateDescendingIndexAsync ++ CreateCombinedTextIndexAsync ++ CreateHashedIndexAsync ++ CreateTextIndexAsync ++ DropIndexAsync ++ GetIndexesNamesAsync + +Usage examples: +```csharp + string expectedIndexName = $"myCustomIndexName"; + var option = new IndexCreationOptions + { + Name = expectedIndexName + }; + // Act + // create a text index against the Version property of the document. + var result = await SUT.CreateTextIndexAsync(x => x.Version, option, PartitionKey); + + // Assert + var listOfIndexNames = await SUT.GetIndexesNamesAsync(PartitionKey); + Assert.Contains(expectedIndexName, listOfIndexNames); + + // Cleanup + await SUT.DropIndexAsync(expectedIndexName, PartitionKey); +``` + Please refer to the IntegrationTests (NET45) and CoreIntegrationTests (netstandard2.0) projects for more usage examples. +The `CoreIntegrationTests.Infrastructure.MongoDbTKeyDocumentTestBase` test class is a good start. ## Author **Alexandre Spieser**