//
//  PersistentThingExtension.swift
//  JustOneThing
//
//  Created by Alan Francis on 15/07/2023.
//

import CoreData

extension PersistentThing {
    var asThing: Thing {
        get {
            Thing(text: self.text ?? "[no text]",
                  createdAt: self.createdAt ?? Date.distantPast)
        }
    }
    
    static var request: NSFetchRequest<PersistentThing> {
        get {
            return NSFetchRequest<PersistentThing>(entityName: PersistentThing.entity().name!)
        }
    }
}
