Aggregate functions in SwiftData

Hi, does SwiftData supports aggregate functions through NSExpression for operations like SUM, AVG, MIN, and MAX?

Answered by Frameworks Engineer in 891773022

That sounds like a great idea! Please use Feedback Assistant to provide suggestions and explain your use case in detail

Accepted Answer

That sounds like a great idea! Please use Feedback Assistant to provide suggestions and explain your use case in detail

Hello @Frameworks Engineer @cgontijo,

I filed feedback for that in January 2024.

Basically, the equivalent to NSExpression functions like sum/average/max/median.

https://developer.apple.com/documentation/foundation/nsexpression/1413747-expressionforfunction

  • FB13522377
  • FB13522406
  • FB13521724
  • FB13522412
  • FB13522411
  • FB13522401
  • FB13522382

Feel free to check them. It's blocking me from adopting SwiftData because I can't do any operation on my data set as I have to fetch all objects into memory with SwiftData.

Regards,

Axel

Aggregate functions in SwiftData
 
 
Q