Why is $function deprecated in MongoD 8.0?

We currently make extensive use of the MongoDB $function operator across various scenarios. One key use case involves determining which stage of the pipeline an entry was in at a specific time interval, based on an array of historical changes. Another case leverages the operator to calculate the relative value of the currently processed item, based on other elements within the same array.

While it’s possible to rewrite most of these queries using native MongoDB operations, we’ve found that approach to be significantly less performant. Moreover, the resulting queries tend to be more complex, which impacts both readability and maintainability.

We hope that the $function operator remains available, allowing users the flexibility to decide when and how to use it, based on their specific needs.

4 Likes