Repository パターンは、データアクセスをコレクションのようなインターフェースの背後に抽象化します。ビジネスロジックをデータの保存・取得方法から分離します。アプリケーションをデータソース(データベース、API)から切り離し、テスト容易性と保守性を向上させます。
Repository パターンが行うこと
REPOSITORY → an abstraction layer between business logic and DATA ACCESS:
→ provides a clean interface (like a collection: findById, save, delete, findAll)
→ HIDES how/where data is actually stored (database, API, cache, files)
→ business logic uses the repository, NOT the database directly
→ separate WHAT data operations from HOW they're implemented
例
{
() { }
() { }
() { }
}
user = userRepository.();
