From 93efb73ca7e4ed2baffadd6bc74aa44e5331e503 Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Wed, 16 Mar 2016 11:09:42 +0100 Subject: [PATCH] Added a convenience function to add a collection by name at Runtime to transaction --- arangod/Utils/Transaction.cpp | 13 +++++++++++++ arangod/Utils/Transaction.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/arangod/Utils/Transaction.cpp b/arangod/Utils/Transaction.cpp index 01100a05ce..745e538de0 100644 --- a/arangod/Utils/Transaction.cpp +++ b/arangod/Utils/Transaction.cpp @@ -797,6 +797,19 @@ OperationResult Transaction::anyLocal(std::string const& collectionName, TRI_ERROR_NO_ERROR, false); } +////////////////////////////////////////////////////////////////////////////// +/// @brief add a collection to the transaction for read, at runtime +////////////////////////////////////////////////////////////////////////////// + +void Transaction::addCollectionAtRuntime(std::string const& collectionName) { + + auto cid = resolver()->getCollectionId(collectionName); + if (cid == 0) { + THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); + } + addCollectionAtRuntime(cid); +} + ////////////////////////////////////////////////////////////////////////////// /// @brief return the type of a collection ////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Utils/Transaction.h b/arangod/Utils/Transaction.h index 3beab283f8..65d3efcbd3 100644 --- a/arangod/Utils/Transaction.h +++ b/arangod/Utils/Transaction.h @@ -287,7 +287,11 @@ class Transaction { } } + ////////////////////////////////////////////////////////////////////////////// + /// @brief add a collection to the transaction for read, at runtime + ////////////////////////////////////////////////////////////////////////////// + void addCollectionAtRuntime(std::string const& collectionName); ////////////////////////////////////////////////////////////////////////////// /// @brief return the type of a collection