diff --git a/Projects/Core/DatabaseClient/Interface/DatabaseClientInterface.swift b/Projects/Core/DatabaseClient/Interface/DatabaseClientInterface.swift index e8b0f09..a2dac35 100644 --- a/Projects/Core/DatabaseClient/Interface/DatabaseClientInterface.swift +++ b/Projects/Core/DatabaseClient/Interface/DatabaseClientInterface.swift @@ -31,6 +31,8 @@ public struct DatabaseClient { /// Use delete(_ type:). public var deleteAllTable: @Sendable () async throws -> Void + public var checkHasTable: @Sendable () async throws -> Bool + public func create(object: T) async throws { try await create(object) } diff --git a/Projects/Core/DatabaseClient/Sources/DatabaseClient.swift b/Projects/Core/DatabaseClient/Sources/DatabaseClient.swift index de1519f..a86c4b6 100644 --- a/Projects/Core/DatabaseClient/Sources/DatabaseClient.swift +++ b/Projects/Core/DatabaseClient/Sources/DatabaseClient.swift @@ -79,6 +79,13 @@ extension DatabaseClient: DependencyKey { } else { throw(NSError(domain: "Realm is not initialized", code: 0)) } + }, + checkHasTable: { + if let realmActor { + await realmActor.checkHasTable() + } else { + throw(NSError(domain: "Realm is not initialized", code: 0)) + } } ) } @@ -135,4 +142,8 @@ extension DatabaseClient.RealmActor { realm.deleteAll() } } + + public func checkHasTable() -> Bool{ + return !realm.isEmpty + } } diff --git a/Projects/Feature/MyPageFeature/Sources/MyPage/MyPageCore.swift b/Projects/Feature/MyPageFeature/Sources/MyPage/MyPageCore.swift index 6612087..c404964 100644 --- a/Projects/Feature/MyPageFeature/Sources/MyPage/MyPageCore.swift +++ b/Projects/Feature/MyPageFeature/Sources/MyPage/MyPageCore.swift @@ -42,6 +42,7 @@ public struct MyPageCore { @Dependency(APIClient.self) var apiClient @Dependency(UserService.self) var userService @Dependency(UserDefaultsClient.self) var userDefaultsClient + @Dependency(NetworkTracking.self) var networkTracking public init() {}