데이터보델 설정

날짜가 중복되면 안되기 때문에 primaryKey 를 날짜로 설정했다.

class UserReport: Object {
    
    @Persisted var date: String
    @Persisted var stepCount: Int
    @Persisted var stepGoal: Int
    @Persisted var goalPercent: Double
   // @Persisted var success: Bool
    override static func primaryKey() -> String? {
        return "date"
    }
    convenience init(date: String, stepCount:Int,stepGoal: Int, goalPercent: Double) {
        self.init()
        
        self.date = date
        self.stepCount = stepCount
        self.stepGoal = stepGoal
        self.goalPercent = goalPercent
        //self.success = false
    }
}

add하기