From b82752e2b95eb5a2fb20caadcb634ba74d9c2020 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 19 Mar 2017 12:32:30 +0100 Subject: [PATCH] No deletion anymore --- .../MongoContentRepository_EventHandling.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Squidex.Read.MongoDb/Contents/MongoContentRepository_EventHandling.cs b/src/Squidex.Read.MongoDb/Contents/MongoContentRepository_EventHandling.cs index c9580edf4..d2abc0e59 100644 --- a/src/Squidex.Read.MongoDb/Contents/MongoContentRepository_EventHandling.cs +++ b/src/Squidex.Read.MongoDb/Contents/MongoContentRepository_EventHandling.cs @@ -111,29 +111,22 @@ namespace Squidex.Read.MongoDb.Contents }); } - protected Task On(FieldDeleted @event, EnvelopeHeaders headers) + protected Task On(ContentDeleted @event, EnvelopeHeaders headers) { return ForSchemaIdAsync(@event.SchemaId.Id, collection => { - return collection.UpdateManyAsync(new BsonDocument(), Update.Unset(new StringFieldDefinition($"Data.{@event.FieldId}"))); + return collection.DeleteOneAsync(x => x.Id == headers.AggregateId()); }); } - protected Task On(ContentDeleted @event, EnvelopeHeaders headers) + protected Task On(FieldDeleted @event, EnvelopeHeaders headers) { return ForSchemaIdAsync(@event.SchemaId.Id, collection => { - return collection.DeleteOneAsync(x => x.Id == headers.AggregateId()); + return collection.UpdateManyAsync(new BsonDocument(), Update.Unset(new StringFieldDefinition($"Data.{@event.FieldId}"))); }); } - protected Task On(SchemaDeleted @event, EnvelopeHeaders headers) - { - var collectionName = $"{Prefix}{@event.SchemaId.Id}"; - - return database.DropCollectionAsync(collectionName); - } - private async Task ForSchemaIdAsync(Guid schemaId, Func, Task> action) { var collection = GetCollection(schemaId);