import Foundation
import RealmSwift

public class VehicleNote: Object, Codable, Cloneable {
    @objc public dynamic var id: String = UUID().uuidString
    @objc public dynamic var user: String = ""
    @objc public dynamic var date: TimeInterval = Date().timeIntervalSince1970
    @objc public dynamic var text: String = ""
    
    // MARK: - Cloneable
    
    public required init(copy: VehicleNote) {
        self.id = copy.id
        self.user = copy.user
        self.date = copy.date
        self.text = copy.text
    }
    
    required init() {
        super.init()
    }
    
    public init(text: String) {
        self.text = text
        self.user = Settings.shared.user.email
    }
    
    public override static func primaryKey() -> String? {
        return "id"
    }
}
