@@ -9,18 +9,14 @@ export function navigatingTo(args: EventData) {
99}
1010
1111export class DemoModel extends DemoSharedFirebaseFirestore {
12-
1312 constructor ( ) {
1413 super ( ) ;
15- Promise . all (
16- [
17- this . invalid_field_path ( )
18- ]
19- )
14+ Promise . all ( [ this . init ( ) , this . invalid_field_path ( ) ] ) ;
2015 }
2116
2217 async init ( ) {
23- firebase ( ) . firestore ( )
18+ firebase ( )
19+ . firestore ( )
2420 . collection ( 'users' )
2521 . add ( {
2622 first : 'Ada' ,
@@ -35,7 +31,8 @@ export class DemoModel extends DemoSharedFirebaseFirestore {
3531 } ) ;
3632
3733 const geo = new GeoPoint ( 10 , - 10 ) ;
38- firebase ( ) . firestore ( )
34+ firebase ( )
35+ . firestore ( )
3936 . collection ( 'geo' )
4037 . add ( {
4138 thing : 'it' ,
@@ -48,29 +45,51 @@ export class DemoModel extends DemoSharedFirebaseFirestore {
4845 console . error ( 'Error adding geo document: ' , error ) ;
4946 } ) ;
5047
51-
52- firebase ( ) . firestore ( ) . collection ( 'items' )
48+ firebase ( )
49+ . firestore ( )
50+ . collection ( 'items' )
5351 . 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+ } ) ;
5773 }
74+
5875
5976 async invalid_field_path ( ) {
6077 try {
61- await firebase ( ) . firestore ( )
62- . collection ( "products" )
63- . doc ( "Oq4eU5p4Lj7Eh6dfjbBX" )
78+ await firebase ( )
79+ . firestore ( )
80+ . collection ( 'products' )
81+ . doc ( 'Oq4eU5p4Lj7Eh6dfjbBX' )
6482 . set ( {
65- name : " Product 1" ,
66- ts : Timestamp . fromDate ( new Date ( ) )
83+ name : ' Product 1' ,
84+ ts : Timestamp . fromDate ( new Date ( ) ) ,
6785 } ) ;
68- await firebase ( ) . firestore ( )
69- . collection ( "products" )
70- . doc ( "Oq4eU5p4Lj7Eh6dfjbBX" )
86+ await firebase ( )
87+ . firestore ( )
88+ . collection ( 'products' )
89+ . doc ( 'Oq4eU5p4Lj7Eh6dfjbBX' )
7190 . update ( {
72- name : " Product 2" ,
73- ts : Timestamp . fromDate ( new Date ( ) )
91+ name : ' Product 2' ,
92+ ts : Timestamp . fromDate ( new Date ( ) ) ,
7493 } ) ;
7594 } catch ( error ) {
7695 console . log ( 'error' , error ) ;
0 commit comments