Aggregation stage "$geoNear" is not supported in a user context. A pipeline with this stage must be run as a System User (status 400)

Hey, I am trying to use $geoNear in aggregation in realm-web, but am getting this error.

aggregation stage "$geoNear" is not supported in a user context. A pipeline with this stage must be run as a System User (status 400).

It’s working fine with find() $near. I can’t understand why I need to use system user through a realm function since that would override role-based access.

Not sure about $geoNear specifically, but I know that some aggregation stages have needed to run as a system user in the past as it wasn’t possible/efficient to apply user permissions.

What I’d do is wrap the aggregation in a Realm function that runs as a system user (you could then optionally call that function directly from your app, or make it private and run it from a non-system Realm function.)