@@ -9,18 +9,14 @@ export function navigatingTo(args: EventData) {
9
9
}
10
10
11
11
export class DemoModel extends DemoSharedFirebaseFirestore {
12
-
13
12
constructor ( ) {
14
13
super ( ) ;
15
- Promise . all (
16
- [
17
- this . invalid_field_path ( )
18
- ]
19
- )
14
+ Promise . all ( [ this . init ( ) , this . invalid_field_path ( ) ] ) ;
20
15
}
21
16
22
17
async init ( ) {
23
- firebase ( ) . firestore ( )
18
+ firebase ( )
19
+ . firestore ( )
24
20
. collection ( 'users' )
25
21
. add ( {
26
22
first : 'Ada' ,
@@ -35,7 +31,8 @@ export class DemoModel extends DemoSharedFirebaseFirestore {
35
31
} ) ;
36
32
37
33
const geo = new GeoPoint ( 10 , - 10 ) ;
38
- firebase ( ) . firestore ( )
34
+ firebase ( )
35
+ . firestore ( )
39
36
. collection ( 'geo' )
40
37
. add ( {
41
38
thing : 'it' ,
@@ -48,29 +45,51 @@ export class DemoModel extends DemoSharedFirebaseFirestore {
48
45
console . error ( 'Error adding geo document: ' , error ) ;
49
46
} ) ;
50
47
51
-
52
- firebase ( ) . firestore ( ) . collection ( 'items' )
48
+ firebase ( )
49
+ . firestore ( )
50
+ . collection ( 'items' )
53
51
. get ( )
54
- . then ( items => {
55
- console . log ( items . docs [ 0 ] . data ( ) )
56
- } )
52
+ . then ( ( items ) => {
53
+ console . log ( items . docs [ 0 ] . data ( ) ) ;
54
+ } ) ;
55
+
56
+ const exampleDoc = firebase ( ) . firestore ( ) . collection ( 'things' ) . doc ( 'exampleDoc' ) ;
57
+ const exampleDoc2 = firebase ( ) . firestore ( ) . collection ( 'things' ) . doc ( 'exampleDoc2' ) ;
58
+
59
+ firebase ( )
60
+ . firestore ( )
61
+ . batch ( )
62
+ . set ( exampleDoc , {
63
+ message : 'Hello doc' ,
64
+ } )
65
+ . set ( exampleDoc2 , {
66
+ date : new Date ( ) ,
67
+ } )
68
+ . commit ( )
69
+ . then ( ( ) => { } )
70
+ . catch ( ( error ) => {
71
+ console . error ( error ) ;
72
+ } ) ;
57
73
}
74
+
58
75
59
76
async invalid_field_path ( ) {
60
77
try {
61
- await firebase ( ) . firestore ( )
62
- . collection ( "products" )
63
- . doc ( "Oq4eU5p4Lj7Eh6dfjbBX" )
78
+ await firebase ( )
79
+ . firestore ( )
80
+ . collection ( 'products' )
81
+ . doc ( 'Oq4eU5p4Lj7Eh6dfjbBX' )
64
82
. set ( {
65
- name : " Product 1" ,
66
- ts : Timestamp . fromDate ( new Date ( ) )
83
+ name : ' Product 1' ,
84
+ ts : Timestamp . fromDate ( new Date ( ) ) ,
67
85
} ) ;
68
- await firebase ( ) . firestore ( )
69
- . collection ( "products" )
70
- . doc ( "Oq4eU5p4Lj7Eh6dfjbBX" )
86
+ await firebase ( )
87
+ . firestore ( )
88
+ . collection ( 'products' )
89
+ . doc ( 'Oq4eU5p4Lj7Eh6dfjbBX' )
71
90
. update ( {
72
- name : " Product 2" ,
73
- ts : Timestamp . fromDate ( new Date ( ) )
91
+ name : ' Product 2' ,
92
+ ts : Timestamp . fromDate ( new Date ( ) ) ,
74
93
} ) ;
75
94
} catch ( error ) {
76
95
console . log ( 'error' , error ) ;
0 commit comments