Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/realm #13

Merged
merged 12 commits into from
Nov 16, 2022
Merged

Feature/realm #13

merged 12 commits into from
Nov 16, 2022

Conversation

Jeonhui
Copy link
Member

@Jeonhui Jeonhui commented Nov 15, 2022

πŸ“• Issue Number

Close #6

πŸ“™ μž‘μ—… λ‚΄μ—­

κ΅¬ν˜„ λ‚΄μš© 및 μž‘μ—… ν–ˆλ˜ λ‚΄μ—­

  • Realm Storage (Realm 관리 update, fetch)
import RealmSwift
import Foundation

enum RealmStorageError: Error {
    case realmObjectError
    case noDataError
    case readError(Error)
    case saveError(Error)
    case deleteError(Error)
}

final class RealmStorage {
    static let shared = RealmStorage()
    
    private init() {
        // Realm file path
        print(Realm.Configuration.defaultConfiguration.fileURL!)
    }

    private let persistentContainer = try? Realm()

    func updateEntity(entity: Object) throws {
        guard let persistentContainer = persistentContainer else {
            throw RealmStorageError.realmObjectError
        }
        try persistentContainer.write {
            persistentContainer.add(entity)
        }
    }

    func fetchEntities<O: Object>(type: O.Type) throws -> [O] {
        guard let persistentContainer = persistentContainer else {
            throw RealmStorageError.realmObjectError
        }
        return Array(persistentContainer.objects(type))
    }
}
  • UserQuestsStorage
  • UserInfoStorage
  • BrowseQuestsStorage

μœ„ StorageλŠ” λ‹€μŒκ³Ό 같은 ꡬ쑰λ₯Ό 가진닀.

/Data

/persistentStorages

/{kind}Storage

{kind}Storage.swift (protocol)
/RealmStorage

Realm{kind}Storage.swift (protocol κ΅¬ν˜„μ²΄)

/EntityMapping

{kind}Entity+Mapping (realm object <-> DomainObject)

πŸ“˜ μž‘μ—… μœ ν˜•

  • μ‹ κ·œ κΈ°λŠ₯ μΆ”κ°€
  • 버그 μˆ˜μ •
  • λ¦¬νŽ™ν† λ§
  • λ¬Έμ„œ μ—…λ°μ΄νŠΈ

πŸ“‹ 체크리슀트

  • Merge ν•˜λŠ” λΈŒλžœμΉ˜κ°€ μ˜¬λ°”λ₯Έκ°€?
  • μ½”λ”©μ»¨λ²€μ…˜μ„ μ€€μˆ˜ν•˜λŠ”κ°€?
  • PRκ³Ό κ΄€λ ¨μ—†λŠ” 변경사항이 μ—†λŠ”κ°€?
  • λ‚΄ μ½”λ“œμ— λŒ€ν•œ 자기 κ²€ν† κ°€ λ˜μ—ˆλŠ”κ°€?
  • 변경사항이 νš¨κ³Όμ μ΄κ±°λ‚˜ λ™μž‘μ΄ μž‘λ™ν•œλ‹€λŠ” 것을 λ³΄μ¦ν•˜λŠ” ν…ŒμŠ€νŠΈλ₯Ό μΆ”κ°€ν•˜μ˜€λŠ”κ°€?
  • μƒˆλ‘œμš΄ ν…ŒμŠ€νŠΈμ™€ 기쑴의 ν…ŒμŠ€νŠΈκ°€ 변경사항에 λŒ€ν•΄ λ§Œμ‘±ν•˜λŠ”κ°€?

πŸ“ PR 특이 사항

PR을 λ³Ό λ•Œ 주의깊게 λ΄μ•Όν•˜κ±°λ‚˜ λ§ν•˜κ³  싢은 점

  • 특이 사항
    • BrowseQuest ꡬ쑰체 생성
    • Quest uuid μΆ”κ°€



Copy link
Collaborator

@jinwoong16 jinwoong16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

κ³ μƒν•˜μ…¨μ–΄μš”~
저도 λΉ λ₯Έ μ‹œμΌλ‚΄μ— DB κ³΅λΆ€ν•΄μ„œ 더 잘볼 수 있게 ν• κ²Œμš” :)

@@ -8,16 +8,16 @@
import Foundation
import RealmSwift

class UserQuestEntity: Object {
final class UserQuestEntity: Object {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final ν‚€μ›Œλ“œλ‘œ μ„±λŠ₯ν–₯상 μ’‹μ•„μš” ~ :)

@@ -9,16 +9,18 @@ import Foundation

extension BrowseQuestEntity {
convenience init(browseQuest: BrowseQuest) {
let questsEntities = browseQuest.quests.compactMap { UserQuestEntity(quest: $0) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ΄λ ‡κ²Œλ„ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€!

Suggested change
let questsEntities = browseQuest.quests.compactMap { UserQuestEntity(quest: $0) }
let questsEntities = browseQuest.quests.compactMap(UserQuestEntity(quest:))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ§„μ›…λ‹˜μ΄ μ•Œλ €μ£Όμ‹  방법이 더 κΉ”λ”ν•΄λ³΄μ΄λ„€μš” λ¦¬νŒ©ν† λ§ λΈŒλžœμΉ˜νŒŒμ„œ Assertionμ΄λž‘ 같이 κ³ μ³λ³΄κ² μŠ΅λ‹ˆλ‹€

Comment on lines +22 to +23
guard let realmStorage = self?.realmStorage else {
return Disposables.create()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertion μ—λŸ¬λ₯Ό λ„μ›Œμ£Όλ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€. 비둝 앱이 μ£½μ§€λ§Œ, κ°œλ°œν•˜λŠ” λ™μ•ˆμ—λŠ” ν™•μ‹€ν•œ indicateλ₯Ό 받을 수 μžˆμ„ 것 κ°™μ•„μš” :)

Suggested change
guard let realmStorage = self?.realmStorage else {
return Disposables.create()
guard let realmStorage = self?.realmStorage else {
assertionFailure("realm storage is not exist")
return Disposables.create()

@jinwoong16 jinwoong16 merged commit cda75e7 into develop Nov 16, 2022
@jinwoong16 jinwoong16 deleted the feature/realm branch November 23, 2022 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants