File tree Expand file tree Collapse file tree 5 files changed +105
-10
lines changed
examples/react-native/__tests__
examples/generated/react-native
sdk/react-native/realm-database/schemas Expand file tree Collapse file tree 5 files changed +105
-10
lines changed Original file line number Diff line number Diff line change
1
+ import Realm from 'realm' ;
2
+
3
+ // :snippet-start: js-invoice-schema
4
+ class Invoice extends Realm . Object {
5
+ static schema = {
6
+ name : 'Invoice' ,
7
+ // sync Invoice objects one way from your device to your Atlas database.
8
+ asymmetric : true ,
9
+ primaryKey : '_id' ,
10
+ properties : {
11
+ _id : 'objectId' ,
12
+ item : 'string' ,
13
+ quantity : 'int' ,
14
+ price : 'int' ,
15
+ } ,
16
+ } ;
17
+ }
18
+ // :snippet-end:
19
+
20
+ export default Invoice ;
Original file line number Diff line number Diff line change
1
+ import Realm from 'realm' ;
2
+
3
+ // TODO: Replace `static schema` with TS-first models + realm-babel-plugin (https://www.npmjs.com/package/@realm/babel-plugin) approach once realm-babel-plugin version 0.1.2 releases with bug fixes
4
+ // :snippet-start: ts-invoice-schema
5
+ class Invoice extends Realm . Object < Invoice > {
6
+ _id ! : string ;
7
+ item ! : string ;
8
+ quantity ! : number ;
9
+ price ! : number ;
10
+
11
+ static schema = {
12
+ name : 'Invoice' ,
13
+ // sync Invoice objects one way from your device to your Atlas database.
14
+ asymmetric : true ,
15
+ primaryKey : '_id' ,
16
+ properties : {
17
+ _id : 'objectId' ,
18
+ item : 'string' ,
19
+ quantity : 'int' ,
20
+ price : 'int' ,
21
+ } ,
22
+ } ;
23
+ }
24
+ // :snippet-end:
25
+
26
+ export default Invoice ;
Original file line number Diff line number Diff line change
1
+ class Invoice extends Realm . Object {
2
+ static schema = {
3
+ name : 'Invoice' ,
4
+ // sync Invoice objects one way from your device to your Atlas database.
5
+ asymmetric : true ,
6
+ primaryKey : '_id' ,
7
+ properties : {
8
+ _id : 'objectId' ,
9
+ item : 'string' ,
10
+ quantity : 'int' ,
11
+ price : 'int' ,
12
+ } ,
13
+ } ;
14
+ }
Original file line number Diff line number Diff line change
1
+ class Invoice extends Realm . Object < Invoice > {
2
+ _id ! : string ;
3
+ item ! : string ;
4
+ quantity ! : number ;
5
+ price ! : number ;
6
+
7
+ static schema = {
8
+ name : 'Invoice' ,
9
+ // sync Invoice objects one way from your device to your Atlas database.
10
+ asymmetric : true ,
11
+ primaryKey : '_id' ,
12
+ properties : {
13
+ _id : 'objectId' ,
14
+ item : 'string' ,
15
+ quantity : 'int' ,
16
+ price : 'int' ,
17
+ } ,
18
+ } ;
19
+ }
Original file line number Diff line number Diff line change @@ -18,17 +18,33 @@ If you are using Flexible Sync and need to sync a collection unidirectionally
18
18
from your device to your Atlas database, you can set the ``asymmetric`` property
19
19
on your object schema.
20
20
21
- .. example::
21
+ Example
22
+ ~~~~~~~
22
23
23
- In the following example of a retail app, the client requires large amounts of
24
- invoice data to be recorded rapidly by store employees. The client specifies
25
- that invoice data does not need to be read after employees have recorded it. To
26
- satisfy this requirement, the application developer defines an invoice
27
- collection with its ``asymmetric`` property set to ``true``.
28
-
29
- .. literalinclude:: /examples/generated/node/asymmetric-sync.snippet.asymmetric-sync.js
30
- :language: javascript
31
- :emphasize-lines: 4
24
+ In the following example of a retail app, the client requires large amounts of
25
+ invoice data to be recorded rapidly by store employees. The client specifies
26
+ that invoice data does not need to be read after employees have recorded it. To
27
+ satisfy this requirement, the application developer defines an invoice
28
+ collection with its ``asymmetric`` property set to ``true``.
29
+
30
+ .. tabs-realm-languages::
31
+
32
+ .. tab::
33
+ :tabid: typescript
34
+
35
+ .. literalinclude:: /examples/generated/react-native/ts/Invoice.snippet.ts-invoice-schema.ts
36
+ :language: typescript
37
+ :emphasize-lines: 9
38
+ :linenos:
39
+
40
+ .. tab::
41
+ :tabid: javascript
42
+
43
+ .. literalinclude:: /examples/generated/react-native/js/Invoice.snippet.js-invoice-schema.js
44
+ :language: javascript
45
+ :emphasize-lines: 5
46
+ :linenos:
47
+
32
48
33
49
.. note:: Attempting to Read Asymmetric Sync Objects
34
50
You can’t perform that action at this time.
0 commit comments