You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
760 B
29 lines
760 B
#pragma once |
|
|
|
#include "application/interfaces/IItemRepository.h" |
|
#include <string> |
|
#include <vector> |
|
#include <mutex> |
|
|
|
namespace nxl::autostore::infrastructure { |
|
|
|
class FileItemRepository : public application::IItemRepository |
|
{ |
|
public: |
|
explicit FileItemRepository(std::string_view dbPath); |
|
domain::Item::Id_t save(const domain::Item& item) override; |
|
std::optional<domain::Item> findById(std::string_view id) override; |
|
std::vector<domain::Item> findByUser(std::string_view userId) override; |
|
std::vector<domain::Item> findAll() override; |
|
void remove(std::string_view id) override; |
|
|
|
private: |
|
void load(); |
|
void persist(); |
|
|
|
std::string dbPath; |
|
std::vector<domain::Item> items; |
|
std::mutex mtx; |
|
}; |
|
|
|
} // namespace nxl::autostore::infrastructure
|