Global functions are not supported in this predicate

How can I compare dates within the predicate ? Currently I get "Global functions are not supported in this predicate" error

   filter: #Predicate<Flashcard> { $0.nextReviewAt <= Date.now },
class Flashcard {
   var nextReviewAt: Date
}

Use predicate as a static function

https://developer.apple.com/documentation/swiftdata/filtering-and-sorting-persistent-data#Define-a-filter-using-a-predicate

filter: predicate(),
static func predicate() -> Predicate<Flashcard> { 
  let now = Date()
  return #Predicate<Flashcard> { $0.nextReviewAt <= now } 
}
Global functions are not supported in this predicate
 
 
Q