diff --git a/source/includes/api-details/cpp/crud/delete-all-objects-not-supported.rst b/source/includes/api-details/cpp/crud/delete-all-objects-not-supported.rst new file mode 100644 index 0000000000..8652a07994 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-all-objects-not-supported.rst @@ -0,0 +1,3 @@ +C++ does not currently provide a method to delete all objects in the database. +You can manually iterate through the objects and delete them if you need to +clear the database. diff --git a/source/includes/api-details/cpp/crud/delete-all-objects-of-type-not-supported.rst b/source/includes/api-details/cpp/crud/delete-all-objects-of-type-not-supported.rst new file mode 100644 index 0000000000..0ca1ab07aa --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-all-objects-of-type-not-supported.rst @@ -0,0 +1 @@ +C++ does not currently provide an API to delete all objects of a type. diff --git a/source/includes/api-details/cpp/crud/delete-inverse-relationship-description.rst b/source/includes/api-details/cpp/crud/delete-inverse-relationship-description.rst new file mode 100644 index 0000000000..22eb0a2254 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-inverse-relationship-description.rst @@ -0,0 +1,4 @@ +In this example, a ``Person`` has a to-one relationship to a ``Dog``, +and the ``Dog`` has an inverse relationship to ``Person``. +Setting the ``Person.dog`` relationship to ``nullptr`` removes the inverse +relationship from the ``Dog`` object. diff --git a/source/includes/api-details/cpp/crud/delete-multiple-objects-description.rst b/source/includes/api-details/cpp/crud/delete-multiple-objects-description.rst new file mode 100644 index 0000000000..12d92e20f7 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-multiple-objects-description.rst @@ -0,0 +1 @@ +You can delete multiple objects within a write transaction. \ No newline at end of file diff --git a/source/includes/api-details/cpp/crud/delete-objects-procedure.rst b/source/includes/api-details/cpp/crud/delete-objects-procedure.rst new file mode 100644 index 0000000000..f10dc52bc8 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-objects-procedure.rst @@ -0,0 +1,25 @@ +1. Open a write transaction with :cpp-sdk:`db.write() + `. + +#. Pass the object(s) you want to delete into the write block, or query for + them inside the block. + + .. important:: Objects Must Be Live + + You can only delete live objects. If you are working with a frozen + object or thread-safe reference, you must ``thaw()`` the object or + ``resolve()`` the thread-safe reference before deleting the object. + For more details, refer to :ref:`sdks-threading`. + +#. Call the ``remove()`` method with the object you want to delete as an + argument. + +#. The specified objects are deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. diff --git a/source/includes/api-details/cpp/crud/delete-operations-description.rst b/source/includes/api-details/cpp/crud/delete-operations-description.rst new file mode 100644 index 0000000000..f22d8c9602 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-operations-description.rst @@ -0,0 +1,3 @@ +To delete an object from the database, pass the object to the +:cpp-sdk:`db.remove() function ` +inside of a write transaction. diff --git a/source/includes/api-details/cpp/crud/delete-remove-dictionary-keys-values-description.rst b/source/includes/api-details/cpp/crud/delete-remove-dictionary-keys-values-description.rst new file mode 100644 index 0000000000..68486b7f90 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-remove-dictionary-keys-values-description.rst @@ -0,0 +1,3 @@ +To delete a :cpp-sdk:`map key +`, +pass the key name to ``erase()``. diff --git a/source/includes/api-details/cpp/crud/delete-remove-elements-from-list-description.rst b/source/includes/api-details/cpp/crud/delete-remove-elements-from-list-description.rst new file mode 100644 index 0000000000..49bf1822d3 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-remove-elements-from-list-description.rst @@ -0,0 +1,3 @@ +You can delete a :cpp-sdk:`list element +` +with ``erase()``, or remove all elements from the list with ``clear()``. diff --git a/source/includes/api-details/cpp/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/cpp/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..5cecc53bea --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,3 @@ +You can delete a :cpp-sdk:`set element +` +with ``erase()``, or remove all elements from a set with ``clear()``. diff --git a/source/includes/api-details/cpp/crud/delete-single-object-description.rst b/source/includes/api-details/cpp/crud/delete-single-object-description.rst new file mode 100644 index 0000000000..f22d8c9602 --- /dev/null +++ b/source/includes/api-details/cpp/crud/delete-single-object-description.rst @@ -0,0 +1,3 @@ +To delete an object from the database, pass the object to the +:cpp-sdk:`db.remove() function ` +inside of a write transaction. diff --git a/source/includes/api-details/csharp/crud/delete-all-objects-in-the-database-description.rst b/source/includes/api-details/csharp/crud/delete-all-objects-in-the-database-description.rst new file mode 100644 index 0000000000..5076099b62 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-all-objects-in-the-database-description.rst @@ -0,0 +1,2 @@ +To delete all managed objects in the database, call :dotnet-sdk:`Realm.RemoveAll +`. diff --git a/source/includes/api-details/csharp/crud/delete-all-objects-of-type-description.rst b/source/includes/api-details/csharp/crud/delete-all-objects-of-type-description.rst new file mode 100644 index 0000000000..91c0400e63 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-all-objects-of-type-description.rst @@ -0,0 +1,2 @@ +To delete all objects of a type, call :dotnet-sdk:`Realm.RemoveAll\ +`. \ No newline at end of file diff --git a/source/includes/api-details/csharp/crud/delete-an-object-and-its-related-objects-description.rst b/source/includes/api-details/csharp/crud/delete-an-object-and-its-related-objects-description.rst new file mode 100644 index 0000000000..f9075d7d2e --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-an-object-and-its-related-objects-description.rst @@ -0,0 +1,6 @@ +In the following example, we call :dotnet-sdk:`Realm.RemoveRange\ +` +to remove Ali's ``dogs`` collection, which is a to-many list property +containing one or more ``Dog`` objects. Then, we call :dotnet-sdk:`Realm.Remove() +` to +delete Ali's ``Person`` object itself. diff --git a/source/includes/api-details/csharp/crud/delete-mixed-property-values-description.rst b/source/includes/api-details/csharp/crud/delete-mixed-property-values-description.rst new file mode 100644 index 0000000000..0af96b9e4a --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-mixed-property-values-description.rst @@ -0,0 +1 @@ +To delete the value of a mixed property, set its value to ``Null``. \ No newline at end of file diff --git a/source/includes/api-details/csharp/crud/delete-multiple-objects-description.rst b/source/includes/api-details/csharp/crud/delete-multiple-objects-description.rst new file mode 100644 index 0000000000..40027667e8 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-multiple-objects-description.rst @@ -0,0 +1,3 @@ +To delete multiple objects at the same time, pass an ``IQueryable`` query +for the objects you want to delete to :dotnet-sdk:`Realm.RemoveRange\ +`. diff --git a/source/includes/api-details/csharp/crud/delete-objects-procedure.rst b/source/includes/api-details/csharp/crud/delete-objects-procedure.rst new file mode 100644 index 0000000000..a5edfae82a --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-objects-procedure.rst @@ -0,0 +1,35 @@ +1. Open a write transaction with :dotnet-sdk:`Realm.Write + ` or + :dotnet-sdk:`Realm.WriteAsync + `. + +#. Pass the object(s) you want to delete into the write block, or query for + them inside the block. + + .. important:: Objects Must Be Live + + You can only delete live objects. If you are working with a frozen + object or thread-safe reference, you must query for the live object or + resolve the thread-safe reference before deleting the object. For more + details, refer to :ref:`sdks-threading`. + +#. Call the :dotnet-sdk:`Remove + ` + method with the object you want to delete as an argument. + +#. The specified objects are deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. + +.. tip:: + + You can check whether an object is still valid to use by calling + :dotnet-sdk:`isValid + `. + Deleted objects return ``false``. diff --git a/source/includes/api-details/csharp/crud/delete-operations-description.rst b/source/includes/api-details/csharp/crud/delete-operations-description.rst new file mode 100644 index 0000000000..43eb251e85 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-operations-description.rst @@ -0,0 +1,10 @@ +You can only delete live objects. If you are working with a frozen object, +such as when passing an object across threads, you must query for the frozen +object on the new thread in order to delete it. + +Similarly, if you're passing a :dotnet-sdk:`ThreadSafeReference +` for an object you want to delete, +you must resolve the reference and then delete the resovled object. + +For more information about working with objects across threads, refer to +:ref:`sdks-threading`. diff --git a/source/includes/api-details/csharp/crud/delete-remove-dictionary-keys-values-description.rst b/source/includes/api-details/csharp/crud/delete-remove-dictionary-keys-values-description.rst new file mode 100644 index 0000000000..eac39af6c0 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-remove-dictionary-keys-values-description.rst @@ -0,0 +1 @@ +You can remove dictionary keys and values within a write transaction. diff --git a/source/includes/api-details/csharp/crud/delete-remove-elements-from-list-description.rst b/source/includes/api-details/csharp/crud/delete-remove-elements-from-list-description.rst new file mode 100644 index 0000000000..7bbe645139 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-remove-elements-from-list-description.rst @@ -0,0 +1,16 @@ +You can remove one or more elements from a list within a write transaction. + +Deleting an object from the database will remove it from any lists +where it existed. Therefore, a list of objects will never contain deleted objects. +However, lists of primitive types can contain null values. If you do not +want to allow null values in a list, then either use non-nullable types in +the list declaration (for example, use ``IList`` instead of +``IList``). If you are using the older schema +type definition (your classes derive from the ``RealmObject`` base class), +or you do not have nullability enabled, use the ``[Required]`` attribute if +the list contains nullable reference types, such as ``string`` or ``byte[]``. + +.. important:: Not Supported with Sync + + Non-synced databases support collections of nullable (optional) values, + but synced databases do not. diff --git a/source/includes/api-details/csharp/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/csharp/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..b2f970b395 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,17 @@ +You can remove one or more elements from a set within a write transaction. + +Deleting an object from the database will remove it from any sets +in which it existed. Therefore, a set of objects will never contain null objects. +However, sets of primitive types can contain null values. If you do not +want to allow null values in a set, then either use non-nullable types in +the set declaration (for example, use ``ISet`` instead of +``ISet``). If you are using the older schema +type definition (your classes derive from the ``RealmObject`` base class), +or you do not have nullability enabled, you will need to use the +``[Required]`` attribute if the set contains nullable reference types, such as +``string`` or ``byte[]``. + +.. important:: Not Supported with Sync + + Non-synced databases support collections of nullable (optional) values, + but synced databases do not. diff --git a/source/includes/api-details/csharp/crud/delete-single-object-description.rst b/source/includes/api-details/csharp/crud/delete-single-object-description.rst new file mode 100644 index 0000000000..0af01a9970 --- /dev/null +++ b/source/includes/api-details/csharp/crud/delete-single-object-description.rst @@ -0,0 +1,4 @@ +To delete an object from the database, pass the object to +:dotnet-sdk:`Realm.Remove() +` +inside of a write transaction. diff --git a/source/includes/api-details/dart/crud/delete-all-objects-in-the-database-not-supported.rst b/source/includes/api-details/dart/crud/delete-all-objects-in-the-database-not-supported.rst new file mode 100644 index 0000000000..2762facd52 --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-all-objects-in-the-database-not-supported.rst @@ -0,0 +1,6 @@ +Dart does not provide an API to delete all objects in the database. Instead, +you can iterate through the object types that the database manages and +delete all objects of each type. + +For more information, refer to the Delete All Objects of a Type section on +this page. diff --git a/source/includes/api-details/dart/crud/delete-all-objects-of-type-description.rst b/source/includes/api-details/dart/crud/delete-all-objects-of-type-description.rst new file mode 100644 index 0000000000..689b32f720 --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-all-objects-of-type-description.rst @@ -0,0 +1,2 @@ +Delete all objects of a type in the database with :flutter-sdk:`Realm.deleteAll() ` +in a write transaction block. diff --git a/source/includes/api-details/dart/crud/delete-mixed-property-values-description.rst b/source/includes/api-details/dart/crud/delete-mixed-property-values-description.rst new file mode 100644 index 0000000000..26871b45a9 --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-mixed-property-values-description.rst @@ -0,0 +1 @@ +To delete the value of a mixed property, call ``RealmValue.nullValue()``. diff --git a/source/includes/api-details/dart/crud/delete-multiple-objects-description.rst b/source/includes/api-details/dart/crud/delete-multiple-objects-description.rst new file mode 100644 index 0000000000..7e839d0f1d --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-multiple-objects-description.rst @@ -0,0 +1,2 @@ +Delete multiple objects from the database by calling :flutter-sdk:`Realm.deleteMany() +` in a write transaction block. diff --git a/source/includes/api-details/dart/crud/delete-objects-procedure.rst b/source/includes/api-details/dart/crud/delete-objects-procedure.rst new file mode 100644 index 0000000000..7db23f1aec --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-objects-procedure.rst @@ -0,0 +1,30 @@ +1. Open a write transaction with :flutter-sdk:`realm.write + ` or :flutter-sdk:`realm.writeAsync + `. + +#. Pass the object(s) you want to delete into the write block, or query for + them inside the block. + + .. important:: Objects Must Be Live + + You can only delete live objects. If you are working with a frozen + object, you must query for the live object before deleting the object. + +#. Call the :flutter-sdk:`delete ` + method with the object you want to delete as an argument. + +#. The specified object is deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. + +.. tip:: + + You can check whether an object is still valid to use by checking the + object's :flutter-sdk:`isValid ` + property. Deleted objects return ``false``. diff --git a/source/includes/api-details/dart/crud/delete-operations-description.rst b/source/includes/api-details/dart/crud/delete-operations-description.rst new file mode 100644 index 0000000000..b3372f6ed0 --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-operations-description.rst @@ -0,0 +1,3 @@ +You can only delete live objects. If you are working with a frozen object, +such as when passing an object across isolates, you must query for the frozen +object in order to delete it. diff --git a/source/includes/api-details/dart/crud/delete-remove-dictionary-keys-values-description.rst b/source/includes/api-details/dart/crud/delete-remove-dictionary-keys-values-description.rst new file mode 100644 index 0000000000..0721e64f06 --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-remove-dictionary-keys-values-description.rst @@ -0,0 +1,4 @@ +You can remove keys and values from a :flutter-sdk:`RealmMap +` within a write transaction. To remove a key and +its associated value, call ``map.remove()``. To remove an element matching +a query, call ``map.removeWhere()``. diff --git a/source/includes/api-details/dart/crud/delete-remove-elements-from-list-description.rst b/source/includes/api-details/dart/crud/delete-remove-elements-from-list-description.rst new file mode 100644 index 0000000000..6ab413a4aa --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-remove-elements-from-list-description.rst @@ -0,0 +1,10 @@ +You can remove one or more elements from a :flutter-sdk:`RealmList +` within a write transaction: + +- To remove one element from the list, pass the element to ``list.remove()``. +- To remove one element at a specified index in the list, pass the index to + ``list.removeAt()``. +- To remove multiple contiguous elements from the list, pass the range to + ``list.removeRange()``. +- To remove the last element from the list, call ``list.removeLast()``. +- To remove specific elements from a list that match a query, call ``list.removeWhere()``. diff --git a/source/includes/api-details/dart/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/dart/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..e1124c31bb --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,6 @@ +You can remove one or more elements from a :flutter-sdk:`RealmSet +` within a write transaction: + +- To remove one element from the set, pass the element to ``set.remove()``. +- To remove specific elements from a set that match a query, call ``set.removeWhere()``. +- To remove all elements from the set, call ``set.removeAll()``. diff --git a/source/includes/api-details/dart/crud/delete-single-object-description.rst b/source/includes/api-details/dart/crud/delete-single-object-description.rst new file mode 100644 index 0000000000..8daeb52847 --- /dev/null +++ b/source/includes/api-details/dart/crud/delete-single-object-description.rst @@ -0,0 +1,2 @@ +Delete an object from the database by calling :flutter-sdk:`Realm.delete() +` in a write transaction block. diff --git a/source/includes/api-details/java/crud/delete-all-objects-in-the-database-description.rst b/source/includes/api-details/java/crud/delete-all-objects-in-the-database-description.rst new file mode 100644 index 0000000000..17b3337b60 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-all-objects-in-the-database-description.rst @@ -0,0 +1,3 @@ +The following example demonstrates how to delete everything +from the database with :java-sdk:`deleteAll() +`. diff --git a/source/includes/api-details/java/crud/delete-all-objects-of-type-description.rst b/source/includes/api-details/java/crud/delete-all-objects-of-type-description.rst new file mode 100644 index 0000000000..cff6e77295 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-all-objects-of-type-description.rst @@ -0,0 +1,3 @@ +The following example demonstrates how to delete all +Turtle instances from the database with :java-sdk:`delete() +`. diff --git a/source/includes/api-details/java/crud/delete-an-object-and-its-related-objects-description.rst b/source/includes/api-details/java/crud/delete-an-object-and-its-related-objects-description.rst new file mode 100644 index 0000000000..9ad58ecd01 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-an-object-and-its-related-objects-description.rst @@ -0,0 +1,3 @@ +The following example demonstrates how to perform a +chaining delete by first deleting all of Ali's turtles, +then deleting Ali. diff --git a/source/includes/api-details/java/crud/delete-mixed-property-values-description.rst b/source/includes/api-details/java/crud/delete-mixed-property-values-description.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/source/includes/api-details/java/crud/delete-multiple-objects-description.rst b/source/includes/api-details/java/crud/delete-multiple-objects-description.rst new file mode 100644 index 0000000000..f7fd4ae654 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-multiple-objects-description.rst @@ -0,0 +1,9 @@ +To delete an object from the database, use the ``deleteAllFromRealm()`` +method of the :java-sdk:`RealmResults ` +instance that contains the objects you would like to delete. You can +filter the ``RealmResults`` down to a subset of objects using the +:java-sdk:`where() ` method. + +The following example demonstrates how to delete a +collection from the database with :java-sdk:`deleteAllFromRealm() +`. diff --git a/source/includes/api-details/java/crud/delete-objects-procedure.rst b/source/includes/api-details/java/crud/delete-objects-procedure.rst new file mode 100644 index 0000000000..6b9b338639 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-objects-procedure.rst @@ -0,0 +1,30 @@ +1. Open a write transaction with one of the relevant APIs. + +#. Pass the object(s) you want to delete into the write block, or query for + them inside the block. + + .. important:: Objects Must Be Live + + You can only delete live objects. If you are working with a frozen + object, you query for the live version of the object on the local thread + before deleting the object. For more details, refer to + :ref:`sdks-threading`. + +#. Call the ``delete()`` method with the object you want to delete as an + argument. + +#. The specified objects are deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. + +.. tip:: + + You can check whether an object is still valid to use by calling + :java-sdk:`isValid() `. + Deleted objects return ``false``. diff --git a/source/includes/api-details/java/crud/delete-operations-description.rst b/source/includes/api-details/java/crud/delete-operations-description.rst new file mode 100644 index 0000000000..e75045386e --- /dev/null +++ b/source/includes/api-details/java/crud/delete-operations-description.rst @@ -0,0 +1,3 @@ +You can only delete live objects. If you are working with a frozen object, +such as when passing an object across threads, you must query for the frozen +object on the new thread in order to delete it. diff --git a/source/includes/api-details/java/crud/delete-remove-dictionary-keys-values-description.rst b/source/includes/api-details/java/crud/delete-remove-dictionary-keys-values-description.rst new file mode 100644 index 0000000000..b436a012b9 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-remove-dictionary-keys-values-description.rst @@ -0,0 +1,2 @@ +For the available methods to remove dictionary keys and values, refer to the +:java-sdk:`RealmMap ` API reference. diff --git a/source/includes/api-details/java/crud/delete-remove-elements-from-list-description.rst b/source/includes/api-details/java/crud/delete-remove-elements-from-list-description.rst new file mode 100644 index 0000000000..7409189d2b --- /dev/null +++ b/source/includes/api-details/java/crud/delete-remove-elements-from-list-description.rst @@ -0,0 +1,2 @@ +For the available methods to remove elements from a list, refer to the +:java-sdk:`RealmList ` API reference. diff --git a/source/includes/api-details/java/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/java/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..aad52f26d5 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,2 @@ +For the available methods to remove elements from a set, refer to the +:java-sdk:`RealmSet ` API reference. diff --git a/source/includes/api-details/java/crud/delete-single-object-description.rst b/source/includes/api-details/java/crud/delete-single-object-description.rst new file mode 100644 index 0000000000..7b69449458 --- /dev/null +++ b/source/includes/api-details/java/crud/delete-single-object-description.rst @@ -0,0 +1,7 @@ +To delete an object from the database, use either the dynamic or static +versions of the ``deleteFromRealm()`` method of a :java-sdk:`RealmObject +` subclass. + +The following example shows how to delete one object from +its realm with :java-sdk:`deleteFromRealm() +`. diff --git a/source/includes/api-details/javascript/crud/delete-all-objects-in-the-database-js-ts-description.rst b/source/includes/api-details/javascript/crud/delete-all-objects-in-the-database-js-ts-description.rst new file mode 100644 index 0000000000..ac6d24b129 --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-all-objects-in-the-database-js-ts-description.rst @@ -0,0 +1,3 @@ +To delete **all** objects from the database, call :js-sdk:`Realm.deleteAll() +` inside of a write transaction. This clears +the database of all object instances but does not affect the database schema. diff --git a/source/includes/api-details/javascript/crud/delete-all-objects-of-type-js-ts-description.rst b/source/includes/api-details/javascript/crud/delete-all-objects-of-type-js-ts-description.rst new file mode 100644 index 0000000000..b6bc053a41 --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-all-objects-of-type-js-ts-description.rst @@ -0,0 +1,3 @@ +To delete all objects of a given object type from the database, pass +``Realm.objects()`` to the :js-sdk:`Realm.delete() +` method inside of a write transaction. diff --git a/source/includes/api-details/javascript/crud/delete-mixed-property-values-js-ts-description.rst b/source/includes/api-details/javascript/crud/delete-mixed-property-values-js-ts-description.rst new file mode 100644 index 0000000000..b3fe5a1e8b --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-mixed-property-values-js-ts-description.rst @@ -0,0 +1 @@ +To delete the value of a ``Mixed`` property, set it to ``null``. \ No newline at end of file diff --git a/source/includes/api-details/javascript/crud/delete-multiple-objects-js-ts-description.rst b/source/includes/api-details/javascript/crud/delete-multiple-objects-js-ts-description.rst new file mode 100644 index 0000000000..3f3b3c41d1 --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-multiple-objects-js-ts-description.rst @@ -0,0 +1,3 @@ +To delete a collection of objects from the database, pass the collection to +:js-sdk:`Realm.delete() ` inside of a write +transaction. diff --git a/source/includes/api-details/javascript/crud/delete-objects-js-ts-procedure.rst b/source/includes/api-details/javascript/crud/delete-objects-js-ts-procedure.rst new file mode 100644 index 0000000000..4432669490 --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-objects-js-ts-procedure.rst @@ -0,0 +1,24 @@ +1. Open a write transaction with :js-sdk:`realm.write + `. + +#. Pass the object(s) you want to delete into the write block, or query for + them inside the block. + +#. Call the :js-sdk:`delete ` + method with the object you want to delete as an argument. + +#. The specified object is deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. + +.. tip:: + + You can check whether an object is still valid to use by calling + :js-sdk:`isValid ` + on the object. Deleted objects return ``false``. diff --git a/source/includes/api-details/javascript/crud/delete-remove-dictionary-keys-values-js-ts-description.rst b/source/includes/api-details/javascript/crud/delete-remove-dictionary-keys-values-js-ts-description.rst new file mode 100644 index 0000000000..53720b0dbe --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-remove-dictionary-keys-values-js-ts-description.rst @@ -0,0 +1,2 @@ +To delete members of a dictionary, use the ``dictionary.remove()`` method with +an array of properties to remove from the dictionary. diff --git a/source/includes/api-details/javascript/crud/delete-remove-elements-from-list-js-ts-description.rst b/source/includes/api-details/javascript/crud/delete-remove-elements-from-list-js-ts-description.rst new file mode 100644 index 0000000000..d6a6faea43 --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-remove-elements-from-list-js-ts-description.rst @@ -0,0 +1,3 @@ +You can remove one or more elements from a :js-sdk:`List ` +within a write transaction. Call :js-sdk:`list.remove() +` with the index of the element you want to remove. diff --git a/source/includes/api-details/javascript/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/javascript/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..1461aa1ac8 --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,8 @@ +To remove a specific value from a set, pass the value to the +``.delete()`` method within a write transaction. + +.. literalinclude:: /examples/generated/node/data-types.snippet.remove-specific-item-from-set.js + :language: javascript + +To remove all items from the set, run the ``.clear()`` method within +a write transaction. diff --git a/source/includes/api-details/javascript/crud/delete-single-object-js-ts-description.rst b/source/includes/api-details/javascript/crud/delete-single-object-js-ts-description.rst new file mode 100644 index 0000000000..e2ef7e2871 --- /dev/null +++ b/source/includes/api-details/javascript/crud/delete-single-object-js-ts-description.rst @@ -0,0 +1,2 @@ +To delete an object from the database, pass the object to :js-sdk:`Realm.delete() +` inside of a write transaction. diff --git a/source/includes/api-details/kotlin/crud/delete-all-objects-in-the-database-description.rst b/source/includes/api-details/kotlin/crud/delete-all-objects-in-the-database-description.rst new file mode 100644 index 0000000000..f19c2d868b --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-all-objects-in-the-database-description.rst @@ -0,0 +1,4 @@ +To delete *all* objects from the database at the same time, call +:kotlin-sdk:`mutableRealm.deleteAll() +`. This deletes all objects of +all types. diff --git a/source/includes/api-details/kotlin/crud/delete-all-objects-of-type-description.rst b/source/includes/api-details/kotlin/crud/delete-all-objects-of-type-description.rst new file mode 100644 index 0000000000..91b876ef3e --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-all-objects-of-type-description.rst @@ -0,0 +1,6 @@ +To delete all objects of a specific type from the database at the same time, +pass the object type to ``query()`` and leave the query filter empty to return +all objects of that type. + +In the following example, we query for all ``Frog`` objects, and then pass +the results to ``mutableRealm.delete()`` to delete them all from the database: diff --git a/source/includes/api-details/kotlin/crud/delete-an-object-and-its-related-objects-description.rst b/source/includes/api-details/kotlin/crud/delete-an-object-and-its-related-objects-description.rst new file mode 100644 index 0000000000..db0759664e --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-an-object-and-its-related-objects-description.rst @@ -0,0 +1,3 @@ +In the following example, we query for a ``Frog`` object named "Kermit", then +iterate through the object's ``favoritePonds`` property and delete +each ``Pond`` object. Then, we delete the ``Frog`` object itself: diff --git a/source/includes/api-details/kotlin/crud/delete-embedded-object-description.rst b/source/includes/api-details/kotlin/crud/delete-embedded-object-description.rst new file mode 100644 index 0000000000..46af648a18 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-embedded-object-description.rst @@ -0,0 +1,15 @@ +.. tip:: Get Embedded Object's Parent + + You can get the unique parent of an embedded object using + :kotlin-sdk:`parent() `. + +In the following example, we have a ``Business`` object with a list of +embedded ``EmbeddedAddress`` objects. We query for and delete the ``Business`` object, +which automatically deletes all of its embedded ``EmbeddedAddress`` objects: + +.. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.delete-embedded-object-through-parent.kt + :language: kotlin + +In the following example, we have ``Contact`` objects with embedded +``EmbeddedAddress`` objects. We delete an ``EmbeddedAddress`` object directly and delete +another through the parent object: diff --git a/source/includes/api-details/kotlin/crud/delete-mixed-property-values-description.rst b/source/includes/api-details/kotlin/crud/delete-mixed-property-values-description.rst new file mode 100644 index 0000000000..87154d1918 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-mixed-property-values-description.rst @@ -0,0 +1,2 @@ +In the following example, we have a ``Frog`` object with a list of +``RealmAny`` properties, and we clear the first ``RealmAny`` property value: diff --git a/source/includes/api-details/kotlin/crud/delete-multiple-objects-description.rst b/source/includes/api-details/kotlin/crud/delete-multiple-objects-description.rst new file mode 100644 index 0000000000..ef3a326651 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-multiple-objects-description.rst @@ -0,0 +1,7 @@ +To delete multiple objects at the same time, pass the object type to +``query()`` and specify a query that returns all objects that you want +to delete. + +In the following example, we query for the first three ``Frog`` objects whose +``species`` is "bullfrog", and then pass the results to +``mutableRealm.delete()`` to delete them from the database: diff --git a/source/includes/api-details/kotlin/crud/delete-objects-procedure.rst b/source/includes/api-details/kotlin/crud/delete-objects-procedure.rst new file mode 100644 index 0000000000..be4c3649d7 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-objects-procedure.rst @@ -0,0 +1,42 @@ +1. Open a write transaction with :kotlin-sdk:`realm.write() + ` or + :kotlin-sdk:`realm.writeBlocking() + `. + +#. Get the live objects by querying the transaction's :kotlin-sdk:`MutableRealm + ` + for the objects that you want to delete using the + :kotlin-sdk:`query() ` method: + + #. Specify the object type as a type parameter passed to ``query()``. + #. (Optional) Filter the set of returned objects by specifying a query. + If you don't include a query filter, you return all objects of the + specified type. For more information on querying with the SDK, refer to + :ref:`sdks-crud-read`. + + .. important:: Objects Must Be Live + + You can only delete live objects. If your query occurs outside of the + write transaction, you must convert the frozen objects + to live objects in the transaction with + ``mutableRealm.findLatest()``. + +#. Pass the set of :kotlin-sdk:`RealmResults + ` returned by the query to + :kotlin-sdk:`mutableRealm.delete() `. + +#. The specified objects are deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. + +.. tip:: + + You can check whether an object is still valid to use by calling + :kotlin-sdk:`isValid() `. + Deleted objects return ``false``. diff --git a/source/includes/api-details/kotlin/crud/delete-operations-description.rst b/source/includes/api-details/kotlin/crud/delete-operations-description.rst new file mode 100644 index 0000000000..6e83fe39a5 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-operations-description.rst @@ -0,0 +1,11 @@ +Write transactions are passed to the database's +:kotlin-sdk:`write() ` or +:kotlin-sdk:`writeBlocking() ` +method. Within this callback, you can access a +:kotlin-sdk:`MutableRealm ` +instance and then delete objects within the database. + +You can only delete live objects, which are only accessible inside of a +write transaction. You can convert a frozen object to a +live object in a transaction with :kotlin-sdk:`mutableRealm.findLatest() +`. diff --git a/source/includes/api-details/kotlin/crud/delete-related-objects-description.rst b/source/includes/api-details/kotlin/crud/delete-related-objects-description.rst new file mode 100644 index 0000000000..91cad44161 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-related-objects-description.rst @@ -0,0 +1,3 @@ +In the following example, we have a ``Frog`` object with a list of +``Pond`` objects. After we delete the ``Frog`` object, we confirm that all +``Pond`` objects still remain in the database: diff --git a/source/includes/api-details/kotlin/crud/delete-remove-dictionary-keys-values-description.rst b/source/includes/api-details/kotlin/crud/delete-remove-dictionary-keys-values-description.rst new file mode 100644 index 0000000000..b149702ca7 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-remove-dictionary-keys-values-description.rst @@ -0,0 +1,15 @@ +You can remove +:kotlin-sdk:`RealmDictionary ` +entries in a few ways: + +- To remove the value but keep the key, set the key to ``null`` (the + dictionary's value must be nullable) +- To remove the key and the value, pass the key to + :kotlin-sdk:`remove() ` + +You can also remove *all* keys and values by calling +:kotlin-sdk:`clear() `. + +In the following example, we have a ``Frog`` object with a dictionary of +``String`` values. We remove the dictionary elements in a series of operations +until the dictionary is empty: diff --git a/source/includes/api-details/kotlin/crud/delete-remove-elements-from-list-description.rst b/source/includes/api-details/kotlin/crud/delete-remove-elements-from-list-description.rst new file mode 100644 index 0000000000..9a103be68c --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-remove-elements-from-list-description.rst @@ -0,0 +1,22 @@ +You can remove one or more elements in a single transaction from a +:kotlin-sdk:`RealmList `: + +- To remove one element from the list, pass the element to + :kotlin-sdk:`list.remove() `. +- To remove one element at a specified index in the list, pass the index to + :kotlin-sdk:`list.removeAt() `. +- To remove multiple elements from the list, pass the elements to + :kotlin-sdk:`list.removeAll() `. + +You can also remove *all* list elements at once by calling +:kotlin-sdk:`list.clear() `. + +In the following example, we have a ``Forest`` object with a list of +``Pond`` objects. We remove the list elements in a series of operations until the +list is empty: + +.. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.remove-items-from-list.kt + :language: kotlin + +In the following example, we have a ``Forest`` object with a list of +``Pond`` objects. We remove all list elements with the ``list.clear()`` method: diff --git a/source/includes/api-details/kotlin/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/kotlin/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..a9ade95d58 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,22 @@ +You can remove one or more elements in a single transaction from a +:kotlin-sdk:`RealmSet `: + +- To remove one element from the set, pass the element + you want to delete to + :kotlin-sdk:`set.remove() `. +- To remove multiple elements from the set, pass the + elements you want to delete to + :kotlin-sdk:`set.removeAll() `. + +You can also remove *all* set elements at once by calling +:kotlin-sdk:`set.clear() `. + +In the following example, we have a ``Frog`` object with a set of +``Snack`` objects. We remove the set elements in a series of operations until the +set is empty: + +.. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.remove-item-from-set.kt + :language: kotlin + +In the following example, we have a ``Frog`` object with a set of +``Snack`` objects. We remove all set elements with the ``set.clear()`` method: diff --git a/source/includes/api-details/kotlin/crud/delete-single-object-description.rst b/source/includes/api-details/kotlin/crud/delete-single-object-description.rst new file mode 100644 index 0000000000..42b1a289dc --- /dev/null +++ b/source/includes/api-details/kotlin/crud/delete-single-object-description.rst @@ -0,0 +1,7 @@ +To delete a single ``RealmObject`` object, +query for the object type using a filter +that returns the specific object that you want to delete. + +In the following example, we query for a ``Frog`` object with a specific +primary key, and then pass the returned object to ``mutableRealm.delete()`` to +delete it from the database: diff --git a/source/includes/api-details/objectivec/crud/delete-all-objects-in-the-database-description.rst b/source/includes/api-details/objectivec/crud/delete-all-objects-in-the-database-description.rst new file mode 100644 index 0000000000..6a2b548d2e --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-all-objects-in-the-database-description.rst @@ -0,0 +1,5 @@ +To delete all objects from the database, call :objc-sdk:`-[RLMRealm +deleteAllObjects] +` +inside of a write transaction. This clears the database of all object +instances but does not affect the database's schema. diff --git a/source/includes/api-details/objectivec/crud/delete-all-objects-of-type-description.rst b/source/includes/api-details/objectivec/crud/delete-all-objects-of-type-description.rst new file mode 100644 index 0000000000..d375aedb2a --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-all-objects-of-type-description.rst @@ -0,0 +1,8 @@ +To delete all objects of a given object type from the database, pass +the result of :objc-sdk:`+[YourSDKObjectClass +allObjectsInRealm:] +` +to :objc-sdk:`-[Realm deleteObjects:] +` +inside of a write transaction. Replace ``YourSDKObjectClass`` +with your SDK object class name. diff --git a/source/includes/api-details/objectivec/crud/delete-an-object-and-its-related-objects-description.rst b/source/includes/api-details/objectivec/crud/delete-an-object-and-its-related-objects-description.rst new file mode 100644 index 0000000000..d50d5e71d6 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-an-object-and-its-related-objects-description.rst @@ -0,0 +1,4 @@ +In the following example, we have a specific ``Person`` object - ``ali``. +We delete the objects in Ali's ``dogs`` collection, which is a to-many list +property containing one or more ``Dog`` objects. Then, we delete the ``ali`` +``Person`` object itself. diff --git a/source/includes/api-details/objectivec/crud/delete-mixed-property-values-description.rst b/source/includes/api-details/objectivec/crud/delete-mixed-property-values-description.rst new file mode 100644 index 0000000000..022d8de7f0 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-mixed-property-values-description.rst @@ -0,0 +1 @@ +To delete the value of an ``RLMValue``, set it to ``nil``. diff --git a/source/includes/api-details/objectivec/crud/delete-multiple-objects-description.rst b/source/includes/api-details/objectivec/crud/delete-multiple-objects-description.rst new file mode 100644 index 0000000000..0b0c20c760 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-multiple-objects-description.rst @@ -0,0 +1,4 @@ +To delete a collection of objects from the database, pass the +collection to :objc-sdk:`-[Realm deleteObjects:] +` +inside of a write transaction. diff --git a/source/includes/api-details/objectivec/crud/delete-objects-procedure.rst b/source/includes/api-details/objectivec/crud/delete-objects-procedure.rst new file mode 100644 index 0000000000..e9a8fb98af --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-objects-procedure.rst @@ -0,0 +1,34 @@ +1. Open a write transaction with :objc-sdk:`transactionWithBlock + ` or + :objc-sdk:`asyncTransactionWithBlock + `. + +#. Pass the object(s) you want to delete into the write block, or query for + them inside the block. + + .. important:: Objects Must Be Live + + You can only delete live objects. If you are working with a frozen + object or thread-safe reference, you must ``thaw`` the object or + resolve the thread-safe reference before deleting the object. For more + details, refer to :ref:`sdks-threading`. + +#. Call the :objc-sdk:`RLMRealm deleteObject + ` method with + the object to delete. + +#. The specified objects are deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. + +.. tip:: + + You can check whether an object is still valid to use by checking the + :objc-sdk:`invalidated ` + property. Deleted objects return ``true``. diff --git a/source/includes/api-details/objectivec/crud/delete-operations-description.rst b/source/includes/api-details/objectivec/crud/delete-operations-description.rst new file mode 100644 index 0000000000..799e6f7436 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-operations-description.rst @@ -0,0 +1,12 @@ +You can only delete live objects. If you are working with a frozen object, +such as when passing an object across threads, you can convert the frozen +object to a live object by calling the :objc-sdk:`thaw +` method. You can thaw +objects, collections, or database instances. + +Similarly, if you're passing an :objc-sdk:`RLMThreadSafeReference +` for an object you want to delete, you +must resolve the reference and then delete the resovled object. + +For more information about working with objects across threads, refer to +:ref:`sdks-threading`. diff --git a/source/includes/api-details/objectivec/crud/delete-remove-dictionary-keys-values-description.rst b/source/includes/api-details/objectivec/crud/delete-remove-dictionary-keys-values-description.rst new file mode 100644 index 0000000000..7ece98cd01 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-remove-dictionary-keys-values-description.rst @@ -0,0 +1,12 @@ +You can remove :objc-sdk:`RLMDictionary ` +entries in a few ways: + +- To remove the value but keep the key, set the key to ``null`` (the + dictionary's value must be nullable) +- To remove the key and the value, pass the key to + :objc-sdk:`removeObjectForKey ` +- To remove keys specified by elements in a given array, pass the array to + :objc-sdk:`removeObjectsForKeys ` + +You can also remove *all* keys and values by calling +:objc-sdk:`removeAllObjects `. diff --git a/source/includes/api-details/objectivec/crud/delete-remove-elements-from-list-description.rst b/source/includes/api-details/objectivec/crud/delete-remove-elements-from-list-description.rst new file mode 100644 index 0000000000..7465bff892 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-remove-elements-from-list-description.rst @@ -0,0 +1,10 @@ +You can remove one or more elements from a :objc-sdk:`RLMArray ` +within a write transaction: + +- To remove one element at a specified index in the list, pass the index to + :objc-sdk:`removeObjectAtIndex `. +- To remove the last element from the list, call + :objc-sdk:`removeLastObject `. + +You can also remove *all* list elements at once by calling +:objc-sdk:`removeAllObjects `. diff --git a/source/includes/api-details/objectivec/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/objectivec/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..d4a9609dbc --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,18 @@ +You can remove one or more elements from a :objc-sdk:`RLMSet +` in a write transaction. + +- To remove one element from the + set, call :objc-sdk:`removeObject + ` with the element + you want to delete. +- To remove from the receiving set elements that *aren't* a member of another + set, call :objc-sdk:`intersectSet + ` with the other set + as an argument. +- To remove from the receiving set elements that *are* a member of another set, + call :objc-sdk:`minusSet ` + with the other set as an argument. + +You can remove *all* set elements at once by calling +:objc-sdk:`removeAllObjects +`. \ No newline at end of file diff --git a/source/includes/api-details/objectivec/crud/delete-single-object-description.rst b/source/includes/api-details/objectivec/crud/delete-single-object-description.rst new file mode 100644 index 0000000000..8707f8a923 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/delete-single-object-description.rst @@ -0,0 +1,4 @@ +To delete an object from the database, pass the object to +:objc-sdk:`-[RLMRealm deleteObject:] +` +inside of a write transaction. diff --git a/source/includes/api-details/swift/crud/delete-all-objects-in-the-database-description.rst b/source/includes/api-details/swift/crud/delete-all-objects-in-the-database-description.rst new file mode 100644 index 0000000000..575b4c625a --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-all-objects-in-the-database-description.rst @@ -0,0 +1,5 @@ +To delete all objects from the database, call +:swift-sdk:`Realm.deleteAll() +` inside of a +write transaction. This clears the database of all object instances but does +not affect the database's schema. diff --git a/source/includes/api-details/swift/crud/delete-all-objects-of-type-description.rst b/source/includes/api-details/swift/crud/delete-all-objects-of-type-description.rst new file mode 100644 index 0000000000..db831b5732 --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-all-objects-of-type-description.rst @@ -0,0 +1,5 @@ +To delete all objects of a given object type from the database, query for +objects of the type you want to delete, and pass the result to +:swift-sdk:`Realm.delete(_:) +` +inside of a write transaction. diff --git a/source/includes/api-details/swift/crud/delete-an-object-and-its-related-objects-description.rst b/source/includes/api-details/swift/crud/delete-an-object-and-its-related-objects-description.rst new file mode 100644 index 0000000000..589a6c7867 --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-an-object-and-its-related-objects-description.rst @@ -0,0 +1,3 @@ +In the following example, we delete the objects in the ``person.dogs`` +collection, which is a to-many list property containing one or more ``Dog`` +objects. Then, we delete the ``Person`` object itself. diff --git a/source/includes/api-details/swift/crud/delete-mixed-property-values-description.rst b/source/includes/api-details/swift/crud/delete-mixed-property-values-description.rst new file mode 100644 index 0000000000..29cda0460f --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-mixed-property-values-description.rst @@ -0,0 +1 @@ +To delete the value of an ``AnyRealmValue``, set it to ``.none``. diff --git a/source/includes/api-details/swift/crud/delete-multiple-objects-description.rst b/source/includes/api-details/swift/crud/delete-multiple-objects-description.rst new file mode 100644 index 0000000000..b75f961c5a --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-multiple-objects-description.rst @@ -0,0 +1,4 @@ +To delete a collection of objects from the database, pass the +collection to :swift-sdk:`Realm.delete(_:) +` +inside of a write transaction. diff --git a/source/includes/api-details/swift/crud/delete-objects-procedure.rst b/source/includes/api-details/swift/crud/delete-objects-procedure.rst new file mode 100644 index 0000000000..6b0b9a1bd3 --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-objects-procedure.rst @@ -0,0 +1,35 @@ +1. Open a write transaction with one of the relevant APIs: + + - :swift-sdk:`write() ` + - :swift-sdk:`writeAsync() ` + - :swift-sdk:`asyncWrite() ` and friends + +#. Pass the object(s) you want to delete into the write block, or query for + them inside the block. + + .. important:: Objects Must Be Live + + You can only delete live objects. If you are working with a frozen + object or thread-safe reference, you must ``thaw()`` the object or + resolve the thread-safe reference before deleting the object. For more + details, refer to :ref:`sdks-threading`. + +#. Call the ``delete()`` method with the object you want to delete as an + argument. + +#. The specified objects are deleted from the database and can no longer be + accessed or modified. If you try to use a deleted object, the SDK throws an + error. + + If any deleted objects had a relationship with another object, the SDK + only deletes the reference to the other object. The referenced object + remains in the database, but it can no longer be queried through the deleted + parent property. Refer to the :ref:`sdks-delete-related-objects` section + for more information. + +.. tip:: + + You can check whether an object is still valid to use by calling + :swift-sdk:`isInvalidated() + `. + Deleted objects return ``true``. diff --git a/source/includes/api-details/swift/crud/delete-operations-description.rst b/source/includes/api-details/swift/crud/delete-operations-description.rst new file mode 100644 index 0000000000..8fa4448edf --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-operations-description.rst @@ -0,0 +1,13 @@ +You can only delete live objects. If you are working with a frozen object, +such as when passing an object across threads, you can convert the frozen +object to a live object by calling the :swift-sdk:`thaw() +` method. +You can thaw objects, collections, or database instances. + +Similarly, if you're passing a :swift-sdk:`ThreadSafeReference +` for an object you want to delete, you must +resolve the reference within the write transaction and then delete the resovled +object. + +For more information about working with objects across threads, refer to +:ref:`sdks-threading`. diff --git a/source/includes/api-details/swift/crud/delete-remove-dictionary-keys-values-description.rst b/source/includes/api-details/swift/crud/delete-remove-dictionary-keys-values-description.rst new file mode 100644 index 0000000000..2da117b1f3 --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-remove-dictionary-keys-values-description.rst @@ -0,0 +1,10 @@ +You can delete :swift-sdk:`map ` entries in a few ways: + +- Use ``removeObject(for:)`` to remove the key and the value +- If the dictionary's value is optional, you can set the value of the key to + ``.none`` to keep the key. This sets the key's value to ``nil`` but does + not delete the key. +- Like a Swift dictionary, if you set the key value to ``nil``, this deletes + both the key and the value. +- If the value of a dictionary key is another object, and you delete the + object, the key remains and its value is set to ``nil``. diff --git a/source/includes/api-details/swift/crud/delete-remove-elements-from-list-description.rst b/source/includes/api-details/swift/crud/delete-remove-elements-from-list-description.rst new file mode 100644 index 0000000000..d606ff81d4 --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-remove-elements-from-list-description.rst @@ -0,0 +1,16 @@ +You can remove one or more elements from a :swift-sdk:`List ` +within a write transaction: + +- To remove one element at a specified index in the list, pass the index to + :swift-sdk:`list.removeAt() `. +- To remove multiple contiguous elements from the list, pass the range to + :swift-sdk:`list.removeSubrange() `. +- To remove the first N elements from the beginning or end of a list, call the + :swift-sdk:`list.removeFirst() + ` or + :swift-sdk:`list.removeLast() + ` methods with an + Int number of items to remove from the beginning or end of the list. + +You can also remove *all* list elements at once by calling +:swift-sdk:`list.removeAll() `. diff --git a/source/includes/api-details/swift/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/swift/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..5b0c03a359 --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,4 @@ +You can delete specific elements from a :swift-sdk:`MutableSet +`, or clear all of the elements from the set. +If you are working with multiple sets, you can also remove elements in one +set from the other set; see: :ref:`sdks-update-set-property`. diff --git a/source/includes/api-details/swift/crud/delete-single-object-description.rst b/source/includes/api-details/swift/crud/delete-single-object-description.rst new file mode 100644 index 0000000000..403ffcce70 --- /dev/null +++ b/source/includes/api-details/swift/crud/delete-single-object-description.rst @@ -0,0 +1,4 @@ +To delete an object from the database, pass the object to +:swift-sdk:`Realm.delete(_:) +` +inside of a write transaction. diff --git a/source/includes/api-details/typescript/crud/delete-remove-elements-from-set-description.rst b/source/includes/api-details/typescript/crud/delete-remove-elements-from-set-description.rst new file mode 100644 index 0000000000..51c60dcf68 --- /dev/null +++ b/source/includes/api-details/typescript/crud/delete-remove-elements-from-set-description.rst @@ -0,0 +1,5 @@ +To remove a specific value from a set, pass the value to the +``.delete()`` method within a write transaction. + +To remove all items from the set, run the ``.clear()`` method within +a write transaction. diff --git a/source/includes/sdk-examples/crud/delete-all-objects-in-the-database.rst b/source/includes/sdk-examples/crud/delete-all-objects-in-the-database.rst new file mode 100644 index 0000000000..f20c8cdecf --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-all-objects-in-the-database.rst @@ -0,0 +1,68 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/CRUD/DeleteAll.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-all.java + :language: java + :emphasize-lines: 2 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-all.kt + :language: kotlin + :emphasize-lines: 2 + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-delete-all.js + :language: javascript + :emphasize-lines: 3 + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.delete-all-realm-objects.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.delete-all.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.delete-all.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-all-objects-of-type.rst b/source/includes/sdk-examples/crud/delete-all-objects-of-type.rst new file mode 100644 index 0000000000..352eae3714 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-all-objects-of-type.rst @@ -0,0 +1,67 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/CRUD/DeleteAllOfClass.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.delete-all-objects-of-type.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-all-instances-of-a-type.java + :language: java + :emphasize-lines: 2 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-all-instances-of-a-type.kt + :language: kotlin + :emphasize-lines: 2 + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-delete-all-objects-of-a-specific-type.js + :language: javascript + :emphasize-lines: 3 + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.delete-all-realm-object-types.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.delete-all-of-class.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.delete-all-of-class.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-an-object-and-its-related-objects.rst b/source/includes/sdk-examples/crud/delete-an-object-and-its-related-objects.rst new file mode 100644 index 0000000000..f53b74b0f2 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-an-object-and-its-related-objects.rst @@ -0,0 +1,68 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/CRUD/ChainingDelete.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.cascading-deletes.java + :language: java + :emphasize-lines: 5 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.cascading-deletes.kt + :language: kotlin + :emphasize-lines: 6 + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.chain-delete-realm-list.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.cascading-delete.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.chaining-delete.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-embedded-object.rst b/source/includes/sdk-examples/crud/delete-embedded-object.rst new file mode 100644 index 0000000000..6f79cad6a5 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-embedded-object.rst @@ -0,0 +1,71 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - 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/DeleteTest.snippet.delete-embedded-object.kt + :language: kotlin + + - 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 diff --git a/source/includes/sdk-examples/crud/delete-inverse-relationship.rst b/source/includes/sdk-examples/crud/delete-inverse-relationship.rst new file mode 100644 index 0000000000..67b5dfa7d9 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-inverse-relationship.rst @@ -0,0 +1,71 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/relationships.snippet.delete-inverse-relationship.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/MissingPlaceholders/example.kt + :language: kotlin + :copyable: false + + - 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 diff --git a/source/includes/sdk-examples/crud/delete-mixed-property-values.rst b/source/includes/sdk-examples/crud/delete-mixed-property-values.rst new file mode 100644 index 0000000000..c977ca0061 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-mixed-property-values.rst @@ -0,0 +1,70 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - 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/DeleteTest.snippet.delete-realmany-property.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.mixed-data-type.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-multiple-objects.rst b/source/includes/sdk-examples/crud/delete-multiple-objects.rst new file mode 100644 index 0000000000..615fecdd29 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-multiple-objects.rst @@ -0,0 +1,67 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/CRUD/DeleteCollection.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.delete-multiple-objects.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-a-collection.java + :language: java + :emphasize-lines: 4 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-a-collection.kt + :language: kotlin + :emphasize-lines: 6 + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-delete-multiple-objects.js + :language: javascript + :emphasize-lines: 5 + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.delete-multiple-realm-objects.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.delete-collection.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.tsq-delete-collection.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-operations.rst b/source/includes/sdk-examples/crud/delete-operations.rst new file mode 100644 index 0000000000..208edf2a12 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-operations.rst @@ -0,0 +1,66 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.delete-an-object.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/CRUD/Delete.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.delete-one-object.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-an-object.java + :language: java + :emphasize-lines: 4 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-an-object.kt + :language: kotlin + :emphasize-lines: 6 + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-delete-object.js + :language: javascript + :emphasize-lines: 3 + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.fetch-latest-to-delete-object.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.delete.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.delete.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-related-objects.rst b/source/includes/sdk-examples/crud/delete-related-objects.rst new file mode 100644 index 0000000000..22803f8dc0 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-related-objects.rst @@ -0,0 +1,69 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + + - 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/DeleteTest.snippet.delete-realm-object-with-related-objects.kt + :language: kotlin + + - 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 diff --git a/source/includes/sdk-examples/crud/delete-remove-dictionary-keys-values.rst b/source/includes/sdk-examples/crud/delete-remove-dictionary-keys-values.rst new file mode 100644 index 0000000000..cd96da2edc --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-remove-dictionary-keys-values.rst @@ -0,0 +1,68 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.delete-map-value.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/generated/node/data-types.snippet.remove-fields-of-the-dictionary.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.delete-realm-dictionary.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.map.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-remove-elements-from-list.rst b/source/includes/sdk-examples/crud/delete-remove-elements-from-list.rst new file mode 100644 index 0000000000..c257b1d3bb --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-remove-elements-from-list.rst @@ -0,0 +1,71 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - 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/DeleteTest.snippet.list-clear.kt + :language: kotlin + + - 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 diff --git a/source/includes/sdk-examples/crud/delete-remove-elements-from-set.rst b/source/includes/sdk-examples/crud/delete-remove-elements-from-set.rst new file mode 100644 index 0000000000..7b8ee84338 --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-remove-elements-from-set.rst @@ -0,0 +1,68 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.delete-set.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/generated/node/data-types.snippet.remove-all-items-from-set.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.clear-set.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.set-collections.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/delete-single-object.rst b/source/includes/sdk-examples/crud/delete-single-object.rst new file mode 100644 index 0000000000..652f518a2a --- /dev/null +++ b/source/includes/sdk-examples/crud/delete-single-object.rst @@ -0,0 +1,66 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.delete-an-object.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/CRUD/Delete.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.delete-one-object.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-an-object.java + :language: java + :emphasize-lines: 4 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/WritesTest.snippet.delete-an-object.kt + :language: kotlin + :emphasize-lines: 6 + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-delete-object.js + :language: javascript + :emphasize-lines: 3 + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/DeleteTest.snippet.delete-one-realm-object.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.delete.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/DeleteRealmObjects.snippet.delete.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/sdk/crud/delete.txt b/source/sdk/crud/delete.txt index e873cb14c6..dbb0f12027 100644 --- a/source/sdk/crud/delete.txt +++ b/source/sdk/crud/delete.txt @@ -1,8 +1,20 @@ .. _sdks-crud-delete: -============== -Delete Objects -============== +================================== +Delete Objects and Property Values +================================== + +.. meta:: + :description: Learn how to delete objects from the database, clear property values, and remove elements from collections. + :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,956 @@ Delete Objects :depth: 2 :class: singlecol -Placeholder page for content related to deleting objects. +.. tabs-selector:: drivers + +This page describes how to delete objects from a non-synced or synced database +using Atlas Device SDK. + +You can choose to delete a single object, multiple objects, or all +objects from the database. After you delete an object, you can no longer access +or modify it. If you try to use a deleted object, the SDK throws an error. + +Deleting objects from a database *does not* delete the database file or affect +the database schema. It only deletes the object instance from the database. If +you want to delete the database file itself, refer to :ref:`sdks-delete-file`. +If you want to remove objects or properties from the database schema, refer to +:ref:`sdks-change-object-model`. + +.. note:: Write to a Synced Database + + The syntax to delete an object from the database is the same for a non-synced + or a synced database. However, there are additional considerations that + determine whether the delete operation in a synced database is successful. + For more information, refer to :ref:`sdks-write-synced-database`. + +.. _sdks-delete-operations: + +Delete Operations +----------------- + +Delete operations must be performed inside of a **write transaction**. For more information on +write transactions and how the SDK handles them, refer to +:ref:`sdks-write-transactions`. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-operations-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-operations-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-operations-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-operations-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-operations-description.rst + + .. tab:: + :tabid: javascript + + + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-operations-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-operations-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-operations-description.rst + + .. tab:: + :tabid: typescript + + + +.. include:: /includes/sdk-examples/crud/delete-operations.rst + +.. _sdks-related-objects-and-references: + +Related Objects and References +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When you delete an object that has a :ref:`relationship ` +property with another object, the SDK *does not* automatically +delete the instance of the related object. Instead, the SDK only +deletes the *reference* to the other object. The referenced object instance +remains in the database, but it can no longer be queried through the +relationship property. + +:ref:`Embedded objects ` are handled differently. +When you delete an object that contains an embedded object, the SDK +automatically deletes the embedded object in a **cascading delete**. +This is because embedded objects do not have a lifecycle outside of their +parent object. For more information, refer to the +:ref:`sdks-delete-embedded-object` section on this page. + +Chaining Deletes with Related SDK Objects +````````````````````````````````````````` + +If you want to delete any related objects when you delete a parent object, +we recommend performing a **chaining delete**. A chaining delete consists +of manually deleting dependent objects by iterating through the +dependencies and deleting them before deleting the parent object. +For more information on chaining deletes, refer to the +:ref:`sdks-delete-related-objects` section on this page. + +If you do not delete the related objects yourself, they remain in your +database. Whether or not this is a problem depends on your application's +needs. + +.. _sdks-delete-objects-procedure: + +Delete Objects +-------------- + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-objects-js-ts-procedure.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-objects-procedure.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-objects-js-ts-procedure.rst + +.. _sdks-delete-single-object: + +Delete a Single Object +~~~~~~~~~~~~~~~~~~~~~~ + +.. tip:: Use Unique Identifying Information + + We recommend using unique identifying information to find the object you + want to delete, such as a :ref:`primary key ` value, to + ensure your query returns the correct object. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-single-object-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-single-object-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-single-object-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-single-object-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-single-object-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-single-object-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-single-object-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-single-object-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-single-object-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-single-object-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/delete-single-object.rst + +.. _sdks-delete-multiple-objects: + +Delete Multiple Objects +~~~~~~~~~~~~~~~~~~~~~~~ + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-multiple-objects-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-multiple-objects-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-multiple-objects-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/delete-multiple-objects.rst + +.. _sdks-delete-all-objects-of-type: + +Delete All Objects of a Type +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-all-objects-of-type-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-all-objects-of-type-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-all-objects-of-type-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-all-objects-of-type-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-all-objects-of-type-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-all-objects-of-type-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-all-objects-of-type-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-all-objects-of-type-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-all-objects-of-type-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-all-objects-of-type-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/delete-all-objects-of-type.rst + +.. _sdks-delete-all-objects-in-database: + +Delete All Objects in the Database +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The SDK lets you delete all managed objects of all types, which is useful +for quickly clearing out your database while prototyping. For example, instead +of writing a migration to update objects to a new schema, it may be faster to +delete all, and then re-generate the objects with the app itself. + +This does not affect the database schema or any objects that are not managed +by the database instance. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-all-objects-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-all-objects-in-the-database-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-all-objects-in-the-database-not-supported.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-all-objects-in-the-database-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-all-objects-in-the-database-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-all-objects-in-the-database-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-all-objects-in-the-database-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-all-objects-in-the-database-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-all-objects-in-the-database-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-all-objects-in-the-database-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/delete-all-objects-in-the-database.rst + +.. _sdks-delete-related-objects: + +Delete Related Objects +---------------------- + +Deleting an object *does not* automatically delete any objects that are +related to it unless the related object is embedded. Instead, the SDK only +deletes the reference to the related object. + +You can optionally define logic in your app to delete related objects. Or if +an object lifecycle should not outlive a parent object, model it as an embedded +object instead of an independent object with a relationship. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. 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/delete-related-objects-description.rst + + .. tab:: + :tabid: objectivec + + + + .. tab:: + :tabid: swift + + + + .. tab:: + :tabid: typescript + + +.. include:: /includes/sdk-examples/crud/delete-related-objects.rst + +.. _sdks-delete-object-and-its-related-objects: + +Delete an Object and Its Related Objects +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To delete related objects when you delete a parent object, you must manually +delete the related objects yourself. We recommend chaining deletes: +first query for the parent object that you want to delete, then iterate +through the parent object's relationships and delete each related object. +Finally, delete the parent object itself. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-an-object-and-its-related-objects-description.rst + + .. tab:: + :tabid: dart + + + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-an-object-and-its-related-objects-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-an-object-and-its-related-objects-description.rst + + .. tab:: + :tabid: javascript + + + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-an-object-and-its-related-objects-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-an-object-and-its-related-objects-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-an-object-and-its-related-objects-description.rst + + .. tab:: + :tabid: typescript + + +.. include:: /includes/sdk-examples/crud/delete-an-object-and-its-related-objects.rst + +.. _sdks-delete-embedded-object: + +Delete an Embedded Object +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. warning:: The SDK Uses Cascading Deletes for Embedded Objects + + When you delete a ``Realm`` object, the SDK automatically deletes any + embedded objects referenced by that object. This is because embedded objects + are objects tha do not exist independent of the ``Realm`` object, and do + not have their own lifecycle. If you want the referenced objects to persist + after the deletion of the main object, use a regular ``Realm`` object with a + :ref:`to-one relationship ` instead. + +You can delete an embedded object through the parent object in a cascading +delete or by deleting the embedded object directly. + +- To delete the embedded object through the parent object, fetch and delete + the parent object. The SDK automatically deletes all of its embedded objects + from the database. +- To delete an embedded object instance directly: + + - Fetch and delete a specific embedded object. + - Clear the parent's reference to the embedded object, which also + deletes the embedded object instance. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. 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/delete-embedded-object-description.rst + + .. tab:: + :tabid: objectivec + + + + .. tab:: + :tabid: swift + + + + .. tab:: + :tabid: typescript + + +.. include:: /includes/sdk-examples/crud/delete-embedded-object.rst + +.. _sdks-delete-property-values: + +Delete Property Values +---------------------- + +.. _sdks-delete-inverse-relationship: + +Delete an Inverse Relationship +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can't delete an inverse relationship directly. Instead, an +inverse relationship automatically updates by removing the relationship +through the related object. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-inverse-relationship-description.rst + + .. tab:: + :tabid: csharp + + + + .. tab:: + :tabid: dart + + + + .. tab:: + :tabid: java + + + + .. tab:: + :tabid: java-kotlin + + + + .. tab:: + :tabid: javascript + + + + .. tab:: + :tabid: kotlin + + + + .. tab:: + :tabid: objectivec + + + + .. tab:: + :tabid: swift + + + + .. tab:: + :tabid: typescript + + +.. include:: /includes/sdk-examples/crud/delete-inverse-relationship.rst + +.. _sdks-delete-mixed-property-values: + +Delete Mixed Property Values +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Although mixed property instances *cannot* store null values, you can +delete a mixed property value by assigning your language's implementation of +``null`` or ``nil`` directly to the property. For more information on the +mixed data type, refer to :ref:`sdks-mixed-data-type`. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-mixed-property-values-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-mixed-property-values-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-mixed-property-values-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-mixed-property-values-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-mixed-property-values-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-mixed-property-values-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-mixed-property-values-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-mixed-property-values-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-mixed-property-values-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/delete-mixed-property-values.rst + +.. _sdks-remove-elements-from-collections: + +Remove Elements from Collections +-------------------------------- + +SDK collection instances that contain objects only store references to those +objects. You can remove one or more referenced objects from a collection +without deleting the objects themselves. The objects that you remove from a +collection remain in the database until you manually delete them. +Alternatively, deleting an SDK object from a database also deletes that object +from any collection instances that contain the object. + +.. _sdks-remove-elements-from-list: + +Remove Elements from a List +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-remove-elements-from-list-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-remove-elements-from-list-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-remove-elements-from-list-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/delete-remove-elements-from-list.rst + +.. _sdks-remove-elements-from-set: + +Remove Elements from a Set +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-remove-elements-from-set-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/typescript/crud/delete-remove-elements-from-set-description.rst + +.. include:: /includes/sdk-examples/crud/delete-remove-elements-from-set.rst + +.. _sdks-remove-dictionary-keys-values: + +Remove Dictionary Keys/Values +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/delete-remove-dictionary-keys-values-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/delete-remove-dictionary-keys-values-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/delete-remove-dictionary-keys-values-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/delete-remove-dictionary-keys-values.rst diff --git a/source/sdk/crud/update.txt b/source/sdk/crud/update.txt index 2f17611c34..64e6d3abac 100644 --- a/source/sdk/crud/update.txt +++ b/source/sdk/crud/update.txt @@ -16,3 +16,8 @@ Placeholder page for content related to updating realm objects. Update Inverse Relationships ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. _sdks-update-set-property: + +Update a Set Property +~~~~~~~~~~~~~~~~~~~~~