private void Delete(MongoDbTransaction transaction) { var collection = Database.GetCollection <BsonDocument>(transaction.Collection); var filter = GetDocumentFilter(new EtpUri(transaction.Uri), transaction.IdPropertyName); collection.DeleteOne(filter); }
/// <summary> /// Creates a transaction record and attach to the transaction. /// </summary> /// <param name="action">The MongoDb operation, e.g. add.</param> /// <param name="collection">The MongoDb collection name.</param> /// <param name="idPropertyName">Name of the identifier property.</param> /// <param name="document">The data obejct in BsonDocument format.</param> /// <param name="uri">The URI.</param> public void Attach(MongoDbAction action, string collection, string idPropertyName, BsonDocument document, EtpUri?uri = null) { _log.Debug($"Attaching '{action}' transaction for MongoDb collection {collection} with URI: {uri}"); var transaction = new MongoDbTransaction { TransactionId = Id, Collection = collection, IdPropertyName = idPropertyName, Action = action, Status = TransactionStatus.Created, CreatedDateTime = DateTime.UtcNow }; if (uri.HasValue) { transaction.Uri = uri.Value; } if (document != null) { transaction.Value = document; } Transactions.Add(transaction); }