How to call system functions before login?

Hi! I’ve created a function in realm that needs to be run before the login or even the registration. That means that app.currentUser is null. The problem is that I don’t find in the documentation how to do that.

I found this:

const result = await user.functions.sum(numA, numB);
const resultOfCallFunction = await user.callFunction("sum", myArgs); // alternate syntax to call a MongoDB Realm Function
console.log(
  `Using the "functions.sum()" method: the sum of ${numA} + ${numB} = ${result}`
);
console.log(
  `Using the "callFunction()" method: the sum of ${numA} + ${numB} = ${resultOfCallFunction}`
);

This works fine with authenticated users but how do I get system functions? The documentation keep talking about using the “system user”:

But I cannot find anywhere how I can use that user in my app. I just need to call that function.

Have you consider calling this function as anonymous user ?

Hi! I can actually do that but the problem is that for every anon login it will create a record in the Users table from the realm Admin GUI. From doing some test I have already several pages of anon users.

is that the only way?

Another “solution” would be a login using ApiKeys but is that a good practive? Having every customer to log in using those keys for “global” task such as calling functions?