public void TestSparse() { var options = IndexOptions.SetSparse(true); string expected = "{ \"sparse\" : true }"; Assert.AreEqual(expected, options.ToJson()); }
public override void Setup() { base.Setup(); Collection.EnsureIndex( new IndexKeysBuilder().Ascending("EMailLowercase"), IndexOptions.SetSparse(true).SetUnique(true)); Collection.EnsureIndex( new IndexKeysBuilder().Ascending("UserNameLowercase"), IndexOptions.SetUnique(true)); Collection.EnsureIndex( new IndexKeysBuilder().Ascending("ExternalLogins.Provider").Ascending("ExternalLogins.ProviderUserId"), IndexOptions.SetSparse(true).SetUnique(true)); }
private MongoCollection <Schedule> CreateAndIndex() { var collection = Server.GetDatabase(configuration.DatabaseName).GetCollection <Schedule>(configuration.CollectionName); collection.CreateIndex(IndexKeys <Schedule> .Ascending(x => x.CancellationKey), IndexOptions.SetSparse(true)); collection.CreateIndex(IndexKeys <Schedule> .Ascending(x => x.State, x => x.WakeTime)); collection.CreateIndex(IndexKeys <Schedule> .Ascending(x => x.PublishedTime), IndexOptions.SetTimeToLive(configuration.DeleteTimeout).SetSparse(true)); return(collection); }