|
|
|
@ -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<MongoContentEntity>($"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<MongoContentEntity>($"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<IMongoCollection<MongoContentEntity>, Task> action) |
|
|
|
{ |
|
|
|
var collection = GetCollection(schemaId); |
|
|
|
|