Skip to content

Commit

Permalink
Add C++ API descriptions, and a Delete section
Browse files Browse the repository at this point in the history
  • Loading branch information
dacharyc committed Jul 30, 2024
1 parent 2e5b88f commit fcba68e
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
In this example, we use an Atlas Function to create the custom user data. The
Function takes an object passed by the client add 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.

.. include:: /examples/generated/cpp/updateCustomUserData.snippet.update-custom-user-data.js

The following example :ref:`calls a function <sdks-call-a-function>` to
insert a document containing the user ID of the currently logged in user
and a ``favoriteColor`` value into the custom user data collection.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
In this example, we use an Atlas Function to delete the custom user data
document. 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.

.. include:: /examples/generated/cpp/deleteCustomUserData.snippet.delete-custom-user-data.js

The 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
:cpp-sdk:`refresh_custom_user_data()
<structrealm_1_1user.html#a6e08623890de4003a00a351e939a0a9f>`
function to request the latest version of a user's custom data.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
To read the data, access the ``custom_data`` property on the ``User`` object
of a logged-in user.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To update a user's custom user data with an Atlas Function, edit the
MongoDB document whose user ID field contains the user ID of the user.
The following example calls the same function used to create the custom user
data document above. Here, we update the ``favoriteColor`` field of the
the document containing the user ID of the currently logged in user.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
- id: cpp-sdk
content: |

.. literalinclude:: /examples/generated/cpp/asymmetric-sync.snippet.create-asymmetric-object.cpp
:language: cpp
.. literalinclude:: /examples/generated/cpp/custom-user-data.snippet.create.cpp
:language: cpp

- id: csharp
content: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.. tabs-drivers::

tabs:
- id: cpp-sdk
content: |

.. literalinclude:: /examples/generated/cpp/custom-user-data.snippet.delete.cpp
:language: cpp

- id: csharp
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.cs
:language: csharp
:copyable: false

- id: dart
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.dart
:language: dart
:copyable: false

- id: java
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.java
:language: java
:copyable: false

- id: java-kotlin
content: |

.. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt
:language: kotlin
:copyable: false

- id: javascript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.js
:language: javascript
:copyable: false

- id: kotlin
content: |

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

- id: objectivec
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.m
:language: objectivec
:copyable: false

- id: swift
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.swift
:language: swift
:copyable: false

- id: typescript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.ts
:language: typescript
:copyable: false
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
- id: cpp-sdk
content: |

.. literalinclude:: /examples/generated/cpp/asymmetric-sync.snippet.create-asymmetric-object.cpp
:language: cpp
.. literalinclude:: /examples/generated/cpp/custom-user-data.snippet.read.cpp
:language: cpp

- id: csharp
content: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- id: cpp-sdk
content: |

.. literalinclude:: /examples/generated/cpp/asymmetric-sync.snippet.create-asymmetric-object.cpp
.. literalinclude:: /examples/generated/cpp/custom-user-data.snippet.update.cpp
:language: cpp

- id: csharp
Expand Down
85 changes: 75 additions & 10 deletions source/sdk/users/custom-user-data.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ following:
in the App Services documentation
#. :ref:`sdks-connect-to-atlas`

.. _sdks-create-custom-user-data-document:
.. _sdks-create-custom-user-data:

Create a Custom User Data Document
----------------------------------
Create Custom User Data
-----------------------

When you configure custom user data in Atlas, you designate a database and
collection to store the custom user data. This data is stored as documents in
Expand Down Expand Up @@ -84,7 +84,7 @@ ways:
.. tab::
:tabid: cpp-sdk

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

.. tab::
:tabid: csharp
Expand Down Expand Up @@ -119,19 +119,19 @@ ways:
.. tab::
:tabid: objectivec

.. include:: /includes/api-details/objectivec/users/custom-user-data-create-custom-user-data-document-description.rst
.. include:: /includes/api-details/objectivec/users/custom-user-data-create-custom-user-data-description.rst

.. tab::
:tabid: swift

.. include:: /includes/api-details/swift/users/custom-user-data-create-custom-user-data-document-description.rst
.. include:: /includes/api-details/swift/users/custom-user-data-create-custom-user-data-description.rst

.. tab::
:tabid: typescript

.. include:: /includes/api-details/generic/crud/create-asymmetric-object-description.rst

.. include:: /includes/sdk-examples/users/custom-user-data-create-custom-user-data-document.rst
.. include:: /includes/sdk-examples/users/custom-user-data-create-custom-user-data.rst

You can add any number of arbitrary fields and values to the custom user
data document when you create it. The user ID field is the only
Expand All @@ -153,7 +153,7 @@ data, see the Update Custom User Data section on this page.
.. tab::
:tabid: cpp-sdk

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

.. tab::
:tabid: csharp
Expand Down Expand Up @@ -219,7 +219,7 @@ data, see the Update Custom User Data section on this page.
.. tab::
:tabid: cpp-sdk

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

.. tab::
:tabid: csharp
Expand Down Expand Up @@ -286,7 +286,7 @@ You can update custom user data in a few ways:
.. tab::
:tabid: cpp-sdk

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

.. tab::
:tabid: csharp
Expand Down Expand Up @@ -334,3 +334,68 @@ You can update custom user data in a few ways:
.. include:: /includes/api-details/generic/crud/create-asymmetric-object-description.rst

.. include:: /includes/sdk-examples/users/custom-user-data-update-custom-user-data.rst

.. _sdks-delete-custom-user-data:

Delete Custom User Data
-----------------------

Custom user data is stored in a document linked to the user object.
Deleting a user does not delete the custom user data. To fully delete user
data to comply with, for example, :apple:`Apple's Account deletion guidance
<support/offering-account-deletion-in-your-app/>`, you must manually delete
the user's custom data document.

You can delete custom user data in a few ways:

- Define a Function that you call to delete custom user data.
- Access MongoDB through the SDK, if your language supports it, and delete
the user data document from the custom user data collection directly.
- Manually delete a custom data document through:

- :compass:`MongoDB Compass </>`
- :atlas:`MongoDB Atlas Data Explorer </data-explorer/>`

.. tabs-drivers::

.. tab::
:tabid: cpp-sdk

.. include:: /includes/api-details/cpp/users/custom-user-data-delete-custom-user-data-description.rst

.. tab::
:tabid: csharp

.. tab::
:tabid: dart

.. tab::
:tabid: java


.. tab::
:tabid: java-kotlin


.. tab::
:tabid: javascript


.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/crud/create-asymmetric-object-description.rst

.. tab::
:tabid: objectivec


.. tab::
:tabid: swift


.. tab::
:tabid: typescript


.. include:: /includes/sdk-examples/users/custom-user-data-delete-custom-user-data.rst

0 comments on commit fcba68e

Please sign in to comment.