Files
metabuilder/dbal/cpp/src/entities/package/delete_package.hpp
T
2025-12-26 00:52:09 +00:00

40 lines
846 B
C++

/**
* @file delete_package.hpp
* @brief Delete package operation
*/
#ifndef DBAL_DELETE_PACKAGE_HPP
#define DBAL_DELETE_PACKAGE_HPP
#include "dbal/types.hpp"
#include "dbal/errors.hpp"
#include "../../store/in_memory_store.hpp"
namespace dbal {
namespace entities {
namespace package {
/**
* Delete a package by ID
*/
inline Result<bool> remove(InMemoryStore& store, const std::string& id) {
if (id.empty()) {
return Error::validationError("Package ID cannot be empty");
}
auto it = store.packages.find(id);
if (it == store.packages.end()) {
return Error::notFound("Package not found: " + id);
}
store.package_ids.erase(it->second.package_id);
store.packages.erase(it);
return Result<bool>(true);
}
} // namespace package
} // namespace entities
} // namespace dbal
#endif