@@ -23,15 +23,14 @@ of the following:
23
23
- **The sync subscription query.**
24
24
- If your write operation doesn't match the query in the subscription,
25
25
the write reverts with a non-fatal compensating write error (ErrorCompensatingWrite).
26
- - **The Device Sync permissions** in your App Services App.
27
- - If your try to write data that doesn't match the Device Sync permissions expression,
28
- the write reverts with a non-fatal permission denied error.
29
- In the client, this shows as an (ErrorCompensatingWrite). On the server,
30
- you can see more details about how the write was denied was by a
31
- write filter in the role.
32
- - To learn more about configuring Device Sync permissions for your app,
33
- refer to :ref:`sync-rules` and the :ref:`flexible-sync-permissions-guide`
34
- in the App Services documentation.
26
+ - **The permissions** in your App Services App.
27
+ - If your try to write data that doesn't match the permissions expression,
28
+ the write reverts with a non-fatal permission denied error. In the client,
29
+ this shows as an error (ErrorCompensatingWrite). On the server, you can see more
30
+ details about how the write was denied was by a write filter in the role.
31
+ - To learn more about configuring permissions for your app, see
32
+ :ref:`sync-rules` and the :ref:`flexible-sync-permissions-guide` in the
33
+ App Services documentation.
35
34
36
35
.. warning:: Multiprocess Sync is Not Supported
37
36
@@ -42,40 +41,35 @@ of the following:
42
41
Determining What Data Syncs
43
42
---------------------------
44
43
45
- The data that you can write to a synced realm is the intersection of your
46
- Device Sync configuration - your queryable fields and permissions - and the
47
- Flexible Sync subscription query that you use when you open the realm.
44
+ The data that you can write to a synced realm is the intersection of your Device
45
+ Sync configuration, your permissions, and the Flexible Sync subscription query
46
+ that you use when you open the realm.
48
47
49
48
The examples on this page use the following configurations and models:
50
49
51
- Device Sync Configuration
52
- ~~~~~~~~~~~~~~~~~~~~~~~~~
50
+ App Services Configuration
51
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
53
52
54
53
Device Sync is configured with the following queryable fields:
55
54
56
- - ``_id`` (this is a queryable field in every Device Sync configuration)
55
+ - ``_id`` (always included)
56
+ - ``miles``
57
57
- ``ownerId``
58
- - ``complexity``
59
58
60
- Device Sync has permissions configured to let users read and write only their own
59
+ The App Services App has permissions configured to let users read and write only their own
61
60
data:
62
61
63
62
.. code-block:: json
64
63
65
64
{
66
- "rules": {},
67
- "defaultRoles": [
68
- {
69
- "name": "owner-read-write",
70
- "applyWhen": {},
71
- "read": {
72
- "ownerId": "%%user.id"
73
- },
74
- "write": {
75
- "ownerId": "%%user.id"
76
- }
77
- }
78
- ]
65
+ "name": "owner-read-write",
66
+ "apply_when": {},
67
+ "document_filters": {
68
+ "read": { "ownerId": "%%user.id" },
69
+ "write": { "ownerId": "%%user.id" }
70
+ },
71
+ "read": true,
72
+ "write": true
79
73
}
80
74
81
75
Client Data Model and Configuration
@@ -96,8 +90,8 @@ is less than or equal to ``4``:
96
90
What Data Syncs?
97
91
~~~~~~~~~~~~~~~~
98
92
99
- The subscription query combined with the Device Sync permissions mean
100
- that the synced realm only syncs objects where:
93
+ The subscription query combined with the permissions mean that the synced realm
94
+ only syncs objects where:
101
95
102
96
- The ``ownerId`` matches the ``user.id`` of the logged-in user (from the permissions)
103
97
- The ``complexity`` property's value is less than or equal to ``4`` (from the subscription query)
@@ -124,11 +118,11 @@ Writes to Flexible Sync realms may broadly fall into one of two categories:
124
118
Successful Writes
125
119
~~~~~~~~~~~~~~~~~
126
120
127
- When the write matches both the :ref:`Device Sync permissions <sync-rules >`
128
- and the :ref:`Flexible Sync subscription query
129
- <swift-manage-flexible-sync-subscriptions>` in the client, the Realm Swift SDK
130
- can successfully write the object to the synced realm. This object syncs
131
- with the App Services backend when the device has a network connection.
121
+ When the write matches both the :ref:`permissions <permissions >` and the
122
+ :ref:`Flexible Sync subscription query
123
+ <swift-manage-flexible-sync-subscriptions>` in the client, the Realm Swift SDK
124
+ can successfully write the object to the synced realm. This object syncs with
125
+ the App Services backend when the device has a network connection.
132
126
133
127
.. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.successful-write.swift
134
128
:language: swift
0 commit comments