mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-02 17:55:07 +00:00
40 lines
846 B
C++
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
|