The examples on this page demonstrate calling an Atlas Function named concatenate
that takes two arguments, concatenates them, and returns the result:
exports = function(a, b) { return a + b;};
Important
Make sure to sanitize client data to protect against code injection when using Functions.
To execute a function from the C++ SDK, use the call_function() member function on the user
object. Pass in the name of the function as a string for the first parameter. This function takes two arguments, which we provide as a string array of arguments:
auto appConfig = realm::App::configuration();appConfig.app_id = APP_ID;auto app = realm::App(appConfig);auto user = app.login(realm::App::credentials::anonymous()).get();auto sync_config = user.flexible_sync_configuration();auto argArray = "[\"john.smith\", \"@companyemail.com\"]";auto result = user.call_function("concatenate", argArray).get();CHECK(result);auto functionResult = result.value();std::cout << "Calling the concatenate function returned " << functionResult << ".\n";
The callback can provide an optional string result, or an optional error. In the example above, we check that the result has a value.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4