For fetching data, there's a fetchCount() available:
let descriptor = FetchDescriptor<Employee>(predicate: #Predicate { $0.salary > 100_000 })
let count = (try? modelContext.fetchCount(descriptor)) ?? 0
Is there a way to use something similar for the @Query property wrapper? This is the current alternative, but it might be loading more than it has to:
@Query(filter: #Predicate<Employee> { $0. salary > 100_000 }) var employees
inside the view:
if !employees.isEmpty {
// show something
}