From e87d33242e5dddad8d7c5c63648903b5792e90e5 Mon Sep 17 00:00:00 2001 From: dacharyc Date: Tue, 16 Jul 2024 15:14:18 -0400 Subject: [PATCH 1/9] Draft consolidated call a Function page --- ...-function-before-you-begin-description.rst | 10 ++ ...las-function-call-function-description.rst | 8 + ...-function-before-you-begin-description.rst | 9 ++ ...las-function-call-function-description.rst | 23 +++ ...-function-before-you-begin-description.rst | 9 ++ ...las-function-call-function-description.rst | 11 ++ ...-function-before-you-begin-description.rst | 10 ++ ...las-function-call-function-description.rst | 8 + ...-function-before-you-begin-description.rst | 9 ++ ...nction-call-function-js-ts-description.rst | 3 + ...-function-before-you-begin-description.rst | 10 ++ ...las-function-call-function-description.rst | 7 + ...-function-before-you-begin-description.rst | 9 ++ ...las-function-call-function-description.rst | 6 + ...-function-before-you-begin-description.rst | 9 ++ ...las-function-call-function-description.rst | 18 +++ ...tant-sanitize-client-data-in-functions.rst | 4 - .../call-atlas-function-call-function.rst | 74 +++++++++ source/sdk/atlas/call-function.txt | 149 +++++++++++++++++- source/sdk/serialization.txt | 5 + 20 files changed, 383 insertions(+), 8 deletions(-) create mode 100644 source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/cpp/atlas/call-atlas-function-call-function-description.rst create mode 100644 source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/csharp/atlas/call-atlas-function-call-function-description.rst create mode 100644 source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/dart/atlas/call-atlas-function-call-function-description.rst create mode 100644 source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst create mode 100644 source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/javascript/atlas/call-atlas-function-call-function-js-ts-description.rst create mode 100644 source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/kotlin/atlas/call-atlas-function-call-function-description.rst create mode 100644 source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst create mode 100644 source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst create mode 100644 source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst delete mode 100644 source/includes/important-sanitize-client-data-in-functions.rst create mode 100644 source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst diff --git a/source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..952fba68d3 --- /dev/null +++ b/source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,10 @@ +The example on this page demonstrates calling an :ref:`Atlas Function ` +named ``concatenate`` that takes two arguments, concatenates them, and +returns the result: + +.. code-block:: javascript + + // concatenate: concatenate two strings + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/cpp/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/cpp/atlas/call-atlas-function-call-function-description.rst new file mode 100644 index 0000000000..debb2b5729 --- /dev/null +++ b/source/includes/api-details/cpp/atlas/call-atlas-function-call-function-description.rst @@ -0,0 +1,8 @@ +To call an Atlas Function, use the +:cpp-sdk:`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. + +The callback can provide an optional string result, or an optional error. +In this example, we check that the result has a value. diff --git a/source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..a61e9ad173 --- /dev/null +++ b/source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,9 @@ +These examples demonstrate calling an :ref:`Atlas Function ` +named ``sum`` that takes two arguments, adds them, and returns the result: + +.. code-block:: javascript + + // sum: adds two numbers + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/csharp/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/csharp/atlas/call-atlas-function-call-function-description.rst new file mode 100644 index 0000000000..e613ba25ce --- /dev/null +++ b/source/includes/api-details/csharp/atlas/call-atlas-function-call-function-description.rst @@ -0,0 +1,23 @@ +To call an Atlas Function, use the +:dotnet-sdk:`Functions.CallAsync() ` +method on the ``User`` object, passing in the name of the function as the first +parameter and the arguments as the remaining parameters: + +.. literalinclude:: /examples/generated/dotnet/FunctionExamples.snippet.callfunc.cs + :language: csharp + +.. note:: + + The ``CallAsync()`` method returns a single ``BsonValue`` object, which you can + deserialize after calling the function or by using the generic + overload. Both of these approaches to deserialization are shown in the + code above. + +A ``BsonValue`` object can hold a single primitive value (as shown in the +example above), or hold a complete BSON document. If +you have a class that maps to the returned object, you can deserialize +to that class by using the generic overload. For example, the following code +calls a function that returns an object from a collection of "RealmTasks". +Since we know the shape of the returned object, we we can deserialize the +``BsonValue`` to a class that we have created, and then we have +access to the properties and methods on that object: diff --git a/source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..1b83b876bb --- /dev/null +++ b/source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,9 @@ +This example demonstrates calling an :ref:`Atlas Function ` +named ``sum`` that takes two arguments, adds them, and returns the result: + +.. code-block:: javascript + + // sum: adds two numbers + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/dart/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/dart/atlas/call-atlas-function-call-function-description.rst new file mode 100644 index 0000000000..50c3d28692 --- /dev/null +++ b/source/includes/api-details/dart/atlas/call-atlas-function-call-function-description.rst @@ -0,0 +1,11 @@ +To call a Function, call :flutter-sdk:`User.functions.call() `. +Pass the Function name as the first argument and all arguments for the Function +in a List as the second argument. + +To include objects as arguments to the Function, +convert them to JSON first. You can do this using the `jsonEncode() +`__ +function included in the built-in ``dart:convert`` library. + +The Function returns a ``dynamic`` value containing :manual:`MongoDB Extended JSON (EJSON) +` deserialized to a native Dart object. diff --git a/source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..18bced6df3 --- /dev/null +++ b/source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,10 @@ +The example on this page demonstrates calling a simple function named +``sum`` that takes two arguments, adds them, and returns the result: + +.. code-block:: javascript + :copyable: false + + // sum: adds two numbers + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst new file mode 100644 index 0000000000..6142b1d01a --- /dev/null +++ b/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst @@ -0,0 +1,8 @@ +To execute a function from the SDK, use the +:java-sdk:`getFunctions() ` +method of the your :java-sdk:`App ` +to retrieve a :java-sdk:`Functions manager <>`. + +Pass the name and parameters of the function you would like to call to +:java-sdk:`callFunction() ` +or :java-sdk:`callFunctionAsync() `: diff --git a/source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..a65b00c8d3 --- /dev/null +++ b/source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,9 @@ +The examples on this page demonstrate calling a simple Atlas Function +named ``sum`` that takes two arguments, adds them, and returns the result: + +.. code-block:: javascript + + // sum: adds two numbers + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/javascript/atlas/call-atlas-function-call-function-js-ts-description.rst b/source/includes/api-details/javascript/atlas/call-atlas-function-call-function-js-ts-description.rst new file mode 100644 index 0000000000..b696350cfe --- /dev/null +++ b/source/includes/api-details/javascript/atlas/call-atlas-function-call-function-js-ts-description.rst @@ -0,0 +1,3 @@ +To call a function, you can either pass its name and arguments to +``User.callFunction()`` or call the function as if it was a method on the +:js-sdk:`User.functions ` property. diff --git a/source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..04e59547d2 --- /dev/null +++ b/source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,10 @@ +For this example, we call an Atlas Function named ``sum`` that takes two +arguments, adds them, and returns the result: + +.. code-block:: javascript + :caption: Atlas Function + + // Add two numbers + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/kotlin/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/kotlin/atlas/call-atlas-function-call-function-description.rst new file mode 100644 index 0000000000..813667d119 --- /dev/null +++ b/source/includes/api-details/kotlin/atlas/call-atlas-function-call-function-description.rst @@ -0,0 +1,7 @@ +To call an Atlas Function, pass its name and all arguments to +:kotlin-sync-sdk:`Functions.call() `. + +You can serialize Function arguments and return values using an EJSON encoder. +For more information, including examples, refer to :ref:`sdks-ejson-encoding-for-atlas`. + +To call this Atlas Function from the SDK: diff --git a/source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..351b8b4a4e --- /dev/null +++ b/source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,9 @@ +This example calls an :ref:`Atlas Function ` named ``concatenate`` +that takes two arguments, concatenates them, and returns the result: + +.. code-block:: javascript + + // concatenate: concatenate two strings + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst new file mode 100644 index 0000000000..fc91b6a312 --- /dev/null +++ b/source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst @@ -0,0 +1,6 @@ +To execute a function in Objective-C, call the :objc-sdk:`callFunctionNamed:arguments:completionBlock: +Classes/RLMUser.html#/c:objc(cs)RLMUser(im)callFunctionNamed:arguments:completionBlock:>`. +method on the :objc-sdk:`RLMUser ` object. + +Provide the Function name, arguments, and completion block to execute when the +Function call is complete. diff --git a/source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst new file mode 100644 index 0000000000..351b8b4a4e --- /dev/null +++ b/source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst @@ -0,0 +1,9 @@ +This example calls an :ref:`Atlas Function ` named ``concatenate`` +that takes two arguments, concatenates them, and returns the result: + +.. code-block:: javascript + + // concatenate: concatenate two strings + exports = function(a, b) { + return a + b; + }; diff --git a/source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst new file mode 100644 index 0000000000..354d633f5a --- /dev/null +++ b/source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst @@ -0,0 +1,18 @@ +To execute a function in Swift, use the ``functions`` object on the currently +logged-in user. + +The ``functions`` object has dynamic members corresponding to functions. +In this case, ``functions.concatenate()`` refers to the ``concatenate`` +function. Pass a ``BSONArray`` of arguments. + +Async/Await +``````````` + +.. literalinclude:: /examples/generated/code/start/Functions.snippet.async-call-a-function.swift + :language: swift + +Completion Handler +`````````````````` + +The trailing closure is the completion handler to call when the function call +is complete. This handler is executed on a non-main global ``DispatchQueue``. diff --git a/source/includes/important-sanitize-client-data-in-functions.rst b/source/includes/important-sanitize-client-data-in-functions.rst deleted file mode 100644 index ba905434f5..0000000000 --- a/source/includes/important-sanitize-client-data-in-functions.rst +++ /dev/null @@ -1,4 +0,0 @@ -.. important:: - - Make sure to sanitize client data to protect against code injection when using - Functions. \ No newline at end of file diff --git a/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst b/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst new file mode 100644 index 0000000000..31ef7f82d6 --- /dev/null +++ b/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst @@ -0,0 +1,74 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/call-function.snippet.call-a-function.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/FunctionExamples.snippet.callfuncWithPOCO.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/functions_test.snippet.call-function.dart + :language: dart + + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/FunctionTest.snippet.call-a-function.java + :language: java + :emphasize-lines: 10-17 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/FunctionTest.snippet.call-a-function.kt + :language: kotlin + :emphasize-lines: 8,9,10,11,12,13,14,15,16,17 + + - id: javascript + content: | + + .. io-code-block:: + + .. input:: /examples/generated/node/call-a-function.snippet.call-a-function-by-name.js + :language: javascript + + .. output:: + :language: console + + Using the "functions.sum()" method: the sum of 2 + 3 = 5 + Using the "callFunction()" method: the sum of 2 + 3 = 5 + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/FunctionsTest.snippet.call-function.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/Functions.snippet.call-a-function.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Functions.snippet.call-a-function.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/sdk/atlas/call-function.txt b/source/sdk/atlas/call-function.txt index c31a89ed61..68ea60a8af 100644 --- a/source/sdk/atlas/call-function.txt +++ b/source/sdk/atlas/call-function.txt @@ -1,8 +1,20 @@ .. _sdks-call-function: -=============== -Call a Function -=============== +====================== +Call an Atlas Function +====================== + +.. meta:: + :description: Call serverless Atlas Functions from a client application with Atlas Device SDK. + :keywords: Realm, C++ SDK, Flutter SDK, Kotlin SDK, Java SDK, .NET SDK, Node.js SDK, Swift SDK, code example + +.. facet:: + :name: genre + :values: reference + +.. facet:: + :name: programming_language + :values: cpp, csharp, dart, java, javascript/typescript, kotlin, objective-c, swift .. contents:: On this page :local: @@ -10,4 +22,133 @@ Call a Function :depth: 2 :class: singlecol -Placeholder page for the call a Function content. +.. tabs-selector:: drivers + +You can call an **Atlas Function** from a client application using Atlas +Device SDK. Functions are serverless JavaScript functions that let you define +and execute server-side logic. These server-side Functions can run in the +context of the authenticated user, and thus honor the rules, roles, and +permissions that you have assigned to your data in Atlas. + +For more information on configuring and writing Atlas Functions, refer to +:ref:`Atlas Functions ` in the App Services documentation. + +Before You Begin +---------------- + +#. In an App Services App, :ref:`define an Atlas Function `. +#. In your client project, :ref:`initialize the App client `. +#. Then, :ref:`authenticate a user `. You access + Functions through the user object. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objc/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst + + .. tab:: + :tabid: typescript + +Call a Function +--------------- + +.. important:: + + Make sure to sanitize client data to protect against code injection when using + Functions. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/atlas/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/atlas/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/atlas/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/atlas/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/atlas/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/generic/atlas/call-atlas-function-call-function-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/atlas/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objc/atlas/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/call-atlas-function-call-function-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/atlas/call-atlas-function-call-function-js-ts-description.rst + +.. include:: /includes/sdk-examples/atlas/call-function-call-function.rst diff --git a/source/sdk/serialization.txt b/source/sdk/serialization.txt index fbbc0e03e5..0fe8d69edf 100644 --- a/source/sdk/serialization.txt +++ b/source/sdk/serialization.txt @@ -11,3 +11,8 @@ Serialization :class: singlecol Placeholder page for information about serialization in the SDKs. + +.. _sdks-ejson-encoding-for-atlas: + +EJSON Encoding +-------------- From b5158aec3a64bab5341d7b34388c68e43f23137e Mon Sep 17 00:00:00 2001 From: dacharyc Date: Tue, 16 Jul 2024 15:24:15 -0400 Subject: [PATCH 2/9] Remove JS example inside code block tab --- ...-function-before-you-begin-description.rst | 10 ---- ...-function-before-you-begin-description.rst | 9 --- ...-function-before-you-begin-description.rst | 9 --- ...-function-before-you-begin-description.rst | 10 ---- ...-function-before-you-begin-description.rst | 9 --- ...-function-before-you-begin-description.rst | 10 ---- ...-function-before-you-begin-description.rst | 9 --- ...-function-before-you-begin-description.rst | 9 --- .../call-atlas-function-call-function.rst | 1 - source/sdk/atlas/call-function.txt | 55 +++---------------- 10 files changed, 8 insertions(+), 123 deletions(-) delete mode 100644 source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst delete mode 100644 source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst delete mode 100644 source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst delete mode 100644 source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst delete mode 100644 source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst delete mode 100644 source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst delete mode 100644 source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst delete mode 100644 source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst diff --git a/source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index 952fba68d3..0000000000 --- a/source/includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,10 +0,0 @@ -The example on this page demonstrates calling an :ref:`Atlas Function ` -named ``concatenate`` that takes two arguments, concatenates them, and -returns the result: - -.. code-block:: javascript - - // concatenate: concatenate two strings - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index a61e9ad173..0000000000 --- a/source/includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,9 +0,0 @@ -These examples demonstrate calling an :ref:`Atlas Function ` -named ``sum`` that takes two arguments, adds them, and returns the result: - -.. code-block:: javascript - - // sum: adds two numbers - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index 1b83b876bb..0000000000 --- a/source/includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,9 +0,0 @@ -This example demonstrates calling an :ref:`Atlas Function ` -named ``sum`` that takes two arguments, adds them, and returns the result: - -.. code-block:: javascript - - // sum: adds two numbers - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index 18bced6df3..0000000000 --- a/source/includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,10 +0,0 @@ -The example on this page demonstrates calling a simple function named -``sum`` that takes two arguments, adds them, and returns the result: - -.. code-block:: javascript - :copyable: false - - // sum: adds two numbers - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index a65b00c8d3..0000000000 --- a/source/includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,9 +0,0 @@ -The examples on this page demonstrate calling a simple Atlas Function -named ``sum`` that takes two arguments, adds them, and returns the result: - -.. code-block:: javascript - - // sum: adds two numbers - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index 04e59547d2..0000000000 --- a/source/includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,10 +0,0 @@ -For this example, we call an Atlas Function named ``sum`` that takes two -arguments, adds them, and returns the result: - -.. code-block:: javascript - :caption: Atlas Function - - // Add two numbers - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index 351b8b4a4e..0000000000 --- a/source/includes/api-details/objectivec/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,9 +0,0 @@ -This example calls an :ref:`Atlas Function ` named ``concatenate`` -that takes two arguments, concatenates them, and returns the result: - -.. code-block:: javascript - - // concatenate: concatenate two strings - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst b/source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst deleted file mode 100644 index 351b8b4a4e..0000000000 --- a/source/includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst +++ /dev/null @@ -1,9 +0,0 @@ -This example calls an :ref:`Atlas Function ` named ``concatenate`` -that takes two arguments, concatenates them, and returns the result: - -.. code-block:: javascript - - // concatenate: concatenate two strings - exports = function(a, b) { - return a + b; - }; diff --git a/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst b/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst index 31ef7f82d6..3f2416a49c 100644 --- a/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst +++ b/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst @@ -19,7 +19,6 @@ .. literalinclude:: /examples/generated/flutter/functions_test.snippet.call-function.dart :language: dart - - id: java content: | diff --git a/source/sdk/atlas/call-function.txt b/source/sdk/atlas/call-function.txt index 68ea60a8af..a542634cfd 100644 --- a/source/sdk/atlas/call-function.txt +++ b/source/sdk/atlas/call-function.txt @@ -41,55 +41,16 @@ Before You Begin #. Then, :ref:`authenticate a user `. You access Functions through the user object. -.. tabs-drivers:: - - .. tab:: - :tabid: cpp-sdk - - .. include:: /includes/api-details/cpp/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: csharp - - .. include:: /includes/api-details/csharp/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: dart - - .. include:: /includes/api-details/dart/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: java - - .. include:: /includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: java-kotlin - - .. include:: /includes/api-details/java/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: javascript +The example on this page demonstrates calling an :ref:`Atlas Function ` +named ``sum`` or ``concatenate`` that takes two arguments, sums or concatenates +them, and returns the result: - .. include:: /includes/api-details/javascript/atlas/call-atlas-function-before-you-begin-description.rst +.. code-block:: javascript - .. tab:: - :tabid: kotlin - - .. include:: /includes/api-details/kotlin/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: objectivec - - .. include:: /includes/api-details/objc/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: swift - - .. include:: /includes/api-details/swift/atlas/call-atlas-function-before-you-begin-description.rst - - .. tab:: - :tabid: typescript + // concatenate: concatenate two strings + exports = function(a, b) { + return a + b; + }; Call a Function --------------- From 3246e8a5e5692bdc15722fbcd71dff91fde97986 Mon Sep 17 00:00:00 2001 From: dacharyc Date: Tue, 16 Jul 2024 15:26:09 -0400 Subject: [PATCH 3/9] Fix include path for code examples --- source/sdk/atlas/call-function.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sdk/atlas/call-function.txt b/source/sdk/atlas/call-function.txt index a542634cfd..7e7d47e560 100644 --- a/source/sdk/atlas/call-function.txt +++ b/source/sdk/atlas/call-function.txt @@ -112,4 +112,4 @@ Call a Function .. include:: /includes/api-details/javascript/atlas/call-atlas-function-call-function-js-ts-description.rst -.. include:: /includes/sdk-examples/atlas/call-function-call-function.rst +.. include:: /includes/sdk-examples/atlas/call-atlas-function-call-function.rst From ac8c34178444fbe39046616e2d15f302112ff3f1 Mon Sep 17 00:00:00 2001 From: dacharyc Date: Tue, 16 Jul 2024 15:30:10 -0400 Subject: [PATCH 4/9] Fix more include paths --- source/sdk/atlas/call-function.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/sdk/atlas/call-function.txt b/source/sdk/atlas/call-function.txt index 7e7d47e560..dcd01dbc2d 100644 --- a/source/sdk/atlas/call-function.txt +++ b/source/sdk/atlas/call-function.txt @@ -100,12 +100,12 @@ Call a Function .. tab:: :tabid: objectivec - .. include:: /includes/api-details/objc/atlas/call-atlas-function-call-function-description.rst + .. include:: /includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst .. tab:: :tabid: swift - .. include:: /includes/api-details/swift/crud/call-atlas-function-call-function-description.rst + .. include:: /includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst .. tab:: :tabid: typescript From 6c52c79685ab9ca2c15526997cf902ec5604a230 Mon Sep 17 00:00:00 2001 From: dacharyc Date: Tue, 16 Jul 2024 15:33:18 -0400 Subject: [PATCH 5/9] Fix broken Objective-C API reference link --- .../atlas/call-atlas-function-call-function-description.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst index fc91b6a312..f44365592d 100644 --- a/source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst +++ b/source/includes/api-details/objectivec/atlas/call-atlas-function-call-function-description.rst @@ -1,5 +1,5 @@ To execute a function in Objective-C, call the :objc-sdk:`callFunctionNamed:arguments:completionBlock: -Classes/RLMUser.html#/c:objc(cs)RLMUser(im)callFunctionNamed:arguments:completionBlock:>`. +`. method on the :objc-sdk:`RLMUser ` object. Provide the Function name, arguments, and completion block to execute when the From d52dda4cfc21d1a3b17d669508b0dcc2b831b747 Mon Sep 17 00:00:00 2001 From: dacharyc Date: Tue, 16 Jul 2024 15:42:18 -0400 Subject: [PATCH 6/9] Fix another include path --- source/sdk/atlas/call-function.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sdk/atlas/call-function.txt b/source/sdk/atlas/call-function.txt index dcd01dbc2d..b6f2e98fb9 100644 --- a/source/sdk/atlas/call-function.txt +++ b/source/sdk/atlas/call-function.txt @@ -90,7 +90,7 @@ Call a Function .. tab:: :tabid: javascript - .. include:: /includes/api-details/generic/atlas/call-atlas-function-call-function-js-ts-description.rst + .. include:: /includes/api-details/javascript/atlas/call-atlas-function-call-function-js-ts-description.rst .. tab:: :tabid: kotlin From c93be5dcdcd0d44b63e69b4f7411032d30962688 Mon Sep 17 00:00:00 2001 From: Dachary Date: Mon, 22 Jul 2024 17:42:55 -0400 Subject: [PATCH 7/9] Apply suggestions from review Co-authored-by: Kyle Rollins <115574589+krollins-mdb@users.noreply.github.com> --- .../atlas/call-atlas-function-call-function-description.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst index 6142b1d01a..1f4f5f7ad8 100644 --- a/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst +++ b/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst @@ -1,8 +1,8 @@ To execute a function from the SDK, use the -:java-sdk:`getFunctions() ` +:java-sdk:`getFunctions() ` method of the your :java-sdk:`App ` to retrieve a :java-sdk:`Functions manager <>`. Pass the name and parameters of the function you would like to call to -:java-sdk:`callFunction() ` -or :java-sdk:`callFunctionAsync() `: +:java-sdk:`callFunction() ` +or :java-sdk:`callFunctionAsync() `: From 69d21eeb70dabe9c919f270fa059ea20f351634f Mon Sep 17 00:00:00 2001 From: dacharyc Date: Mon, 22 Jul 2024 17:54:07 -0400 Subject: [PATCH 8/9] Incorporate review feedback --- ...all-atlas-function-call-function-description.rst | 4 ++-- .../atlas/call-atlas-function-call-function.rst | 13 ++++++++++--- source/sdk/atlas/call-function.txt | 12 ++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst index 354d633f5a..b27ba672b3 100644 --- a/source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst +++ b/source/includes/api-details/swift/atlas/call-atlas-function-call-function-description.rst @@ -1,5 +1,5 @@ -To execute a function in Swift, use the ``functions`` object on the currently -logged-in user. +To execute a function in Swift, use the :swift-sdk:`functions +` object on the currently logged-in user. The ``functions`` object has dynamic members corresponding to functions. In this case, ``functions.concatenate()`` refers to the ``concatenate`` diff --git a/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst b/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst index 3f2416a49c..f227b13d30 100644 --- a/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst +++ b/source/includes/sdk-examples/atlas/call-atlas-function-call-function.rst @@ -68,6 +68,13 @@ - id: typescript content: | - .. literalinclude:: /examples/MissingPlaceholders/example.ts - :language: typescript - :copyable: false + .. io-code-block:: + + .. input:: /examples/generated/node/call-a-function.snippet.call-a-function-by-name.js + :language: javascript + + .. output:: + :language: console + + Using the "functions.sum()" method: the sum of 2 + 3 = 5 + Using the "callFunction()" method: the sum of 2 + 3 = 5 diff --git a/source/sdk/atlas/call-function.txt b/source/sdk/atlas/call-function.txt index b6f2e98fb9..c96db002b3 100644 --- a/source/sdk/atlas/call-function.txt +++ b/source/sdk/atlas/call-function.txt @@ -19,7 +19,7 @@ Call an Atlas Function .. contents:: On this page :local: :backlinks: none - :depth: 2 + :depth: 1 :class: singlecol .. tabs-selector:: drivers @@ -42,15 +42,7 @@ Before You Begin Functions through the user object. The example on this page demonstrates calling an :ref:`Atlas Function ` -named ``sum`` or ``concatenate`` that takes two arguments, sums or concatenates -them, and returns the result: - -.. code-block:: javascript - - // concatenate: concatenate two strings - exports = function(a, b) { - return a + b; - }; +that takes two arguments, performs some work, and returns the result. Call a Function --------------- From d0fab641a00642769076c91ad3f03115697b39d2 Mon Sep 17 00:00:00 2001 From: dacharyc Date: Mon, 22 Jul 2024 17:59:12 -0400 Subject: [PATCH 9/9] Fix remaining Java API reference link --- .../atlas/call-atlas-function-call-function-description.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst b/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst index 1f4f5f7ad8..c1dd254832 100644 --- a/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst +++ b/source/includes/api-details/java/atlas/call-atlas-function-call-function-description.rst @@ -1,7 +1,7 @@ To execute a function from the SDK, use the :java-sdk:`getFunctions() ` method of the your :java-sdk:`App ` -to retrieve a :java-sdk:`Functions manager <>`. +to retrieve a :java-sdk:`Functions manager `. Pass the name and parameters of the function you would like to call to :java-sdk:`callFunction() `