If you create the query property using a FetchDescriptor then you can set a limit for the number of rows being fetched. The drawback of this solution is that it's not a one liner so you need to do it in the init
@Query private var records:[Record]
init() {
var fetchDescriptor = FetchDescriptor<Record>(sortBy: [SortDescriptor(\Record.date, order: .reverse)])
fetchDescriptor.fetchLimit = 7
_categories = Query(fetchDescriptor)
}
If you for some reason don't want to do it in the init you could declare the fetch descriptor as a static variable and then pass it to the @Query declaration
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: