Skip to content

Commit

Permalink
Add Kotlin API descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dacharyc committed Jul 30, 2024
1 parent 7ac37a8 commit 2508109
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This example calls an Atlas Function to create custom user data. In this
example, the Atlas Function takes an object passed by the client and
adds it to the custom user data collection in Atlas.
The Function creates the custom user data if it doesn't already exist and
replaces all data in it if it does exist.

.. literalinclude:: /examples/generated/kotlin/customUserData.snippet.write-custom-user-data.js
:language: js
:caption: writeCustomUserData.js - Atlas Function running on server (JavaScript)

The Kotlin SDK uses the following code to call this Function.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This example calls an Atlas Function to delete custom user data.
In this example, the Atlas Function does not require any arguments.
The Function uses the function context to determine the caller's user ID, and
deletes the custom user data document matching the user's ID.

.. literalinclude:: /examples/generated/kotlin/customUserData.snippet.delete-custom-user-data.js
:language: js
:caption: deleteCustomUserData.js - Atlas Function running on server (JavaScript)

The SDK code that calls this function requires only a logged-in user to
call the function.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. note::

If you require the most recent version of custom user data, use the
:kotlin-sync-sdk:`User.refreshCustomData()
<io.realm.kotlin.mongodb/-user/refresh-custom-data.html>`
method to request the latest version of a user's custom data.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
You can read the custom user data of a currently logged-in user using the
:kotlin-sync-sdk:`User.customDataAsBsonDocument()
<io.realm.kotlin.mongodb.ext/custom-data-as-bson-document.html>`
extension function.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This example calls an Atlas Function to update custom user data. In this
example, the Atlas Function takes an object passed by the client and
adds it to the custom user data collection in Atlas.
The Function creates the custom user data if it doesn't already exist and
replaces all data in it if it does exist.

.. literalinclude:: /examples/generated/kotlin/customUserData.snippet.write-custom-user-data.js
:language: js
:caption: writeCustomUserData.js - Atlas Function running on server (JavaScript)

The Kotlin SDK uses the following code to call this Function.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/AsymmetricSyncTest.snippet.create-asymmetric-object.kt
.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.write-custom-user-data.kt
:language: kotlin
:emphasize-lines: 10, 11

- id: objectivec
content: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/AsymmetricSyncTest.snippet.create-asymmetric-object.kt
.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.delete-custom-user-data.kt
:language: kotlin
:emphasize-lines: 10, 11

- id: objectivec
content: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/AsymmetricSyncTest.snippet.create-asymmetric-object.kt
.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.read-custom-user-data.kt
:language: kotlin
:emphasize-lines: 10, 11

- id: objectivec
content: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/AsymmetricSyncTest.snippet.create-asymmetric-object.kt
.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.write-custom-user-data.kt
:language: kotlin
:emphasize-lines: 10, 11

- id: objectivec
content: |
Expand Down
10 changes: 5 additions & 5 deletions source/sdk/users/custom-user-data.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ways:
.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/crud/create-asymmetric-object-description.rst
.. include:: /includes/api-details/kotlin/users/custom-user-data-create-custom-user-data-description.rst

.. tab::
:tabid: objectivec
Expand Down Expand Up @@ -183,7 +183,7 @@ data, see the Update Custom User Data section on this page.
.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/crud/create-asymmetric-object-description.rst
.. include:: /includes/api-details/kotlin/users/custom-user-data-read-custom-user-data-description.rst

.. tab::
:tabid: objectivec
Expand Down Expand Up @@ -249,7 +249,7 @@ data, see the Update Custom User Data section on this page.
.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/crud/create-asymmetric-object-description.rst
.. include:: /includes/api-details/kotlin/users/custom-user-data-read-custom-user-data-2-description.rst

.. tab::
:tabid: objectivec
Expand Down Expand Up @@ -316,7 +316,7 @@ You can update custom user data in a few ways:
.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/crud/create-asymmetric-object-description.rst
.. include:: /includes/api-details/kotlin/users/custom-user-data-update-custom-user-data-description.rst

.. tab::
:tabid: objectivec
Expand Down Expand Up @@ -386,7 +386,7 @@ You can delete custom user data in a few ways:
.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/crud/create-asymmetric-object-description.rst
.. include:: /includes/api-details/kotlin/users/custom-user-data-delete-custom-user-data-description.rst

.. tab::
:tabid: objectivec
Expand Down

0 comments on commit 2508109

Please sign in to comment.