@@ -8,64 +8,55 @@ export const firestoreDocumentOnCreateTests: any = functions
88 timeoutSeconds : 540 ,
99 } )
1010 . region ( REGION )
11- . firestore . document ( "tests/{documentId }" )
11+ . firestore . document ( "tests/{testId }" )
1212 . onCreate ( async ( snapshot , context ) => {
13- const documentId = context . params . documentId ;
13+ const testId = context . params . testId ;
1414 try {
1515 await admin
1616 . firestore ( )
1717 . collection ( "firestoreDocumentOnCreateTests" )
18- . doc ( documentId )
18+ . doc ( testId )
1919 . set ( sanitizeData ( context ) ) ;
2020 } catch ( error ) {
21- console . error (
22- `Error in Firestore document onCreate function for testId: ${ documentId } ` ,
23- error
24- ) ;
21+ console . error ( `Error in Firestore document onCreate function for testId: ${ testId } ` , error ) ;
2522 }
2623 } ) ;
2724
28- export const firestoreDocumentOnUpdateTests : any = functions
25+ export const firestoreDocumentOnDeleteTests : any = functions
2926 . runWith ( {
3027 timeoutSeconds : 540 ,
3128 } )
3229 . region ( REGION )
33- . firestore . document ( "tests/{documentId }" )
34- . onUpdate ( async ( change , context ) => {
35- const documentId = context . params . documentId ;
30+ . firestore . document ( "tests/{testId }" )
31+ . onDelete ( async ( snapshot , context ) => {
32+ const testId = context . params . testId ;
3633 try {
3734 await admin
3835 . firestore ( )
39- . collection ( "firestoreDocumentOnUpdateTests " )
40- . doc ( documentId )
36+ . collection ( "firestoreDocumentOnDeleteTests " )
37+ . doc ( testId )
4138 . set ( sanitizeData ( context ) ) ;
4239 } catch ( error ) {
43- console . error (
44- `Error in Firestore document onUpdate function for testId: ${ documentId } ` ,
45- error
46- ) ;
40+ console . error ( `Error in Firestore document onDelete function for testId: ${ testId } ` , error ) ;
4741 }
4842 } ) ;
4943
50- export const firestoreDocumentOnDeleteTests : any = functions
44+ export const firestoreDocumentOnUpdateTests : any = functions
5145 . runWith ( {
5246 timeoutSeconds : 540 ,
5347 } )
5448 . region ( REGION )
55- . firestore . document ( "tests/{documentId }" )
56- . onDelete ( async ( snapshot , context ) => {
57- const documentId = context . params . documentId ;
49+ . firestore . document ( "tests/{testId }" )
50+ . onUpdate ( async ( change , context ) => {
51+ const testId = context . params . testId ;
5852 try {
5953 await admin
6054 . firestore ( )
61- . collection ( "firestoreDocumentOnDeleteTests " )
62- . doc ( documentId )
55+ . collection ( "firestoreDocumentOnUpdateTests " )
56+ . doc ( testId )
6357 . set ( sanitizeData ( context ) ) ;
6458 } catch ( error ) {
65- console . error (
66- `Error in Firestore document onDelete function for testId: ${ documentId } ` ,
67- error
68- ) ;
59+ console . error ( `Error in Firestore document onUpdate function for testId: ${ testId } ` , error ) ;
6960 }
7061 } ) ;
7162
@@ -74,19 +65,16 @@ export const firestoreDocumentOnWriteTests: any = functions
7465 timeoutSeconds : 540 ,
7566 } )
7667 . region ( REGION )
77- . firestore . document ( "tests/{documentId }" )
68+ . firestore . document ( "tests/{testId }" )
7869 . onWrite ( async ( change , context ) => {
79- const documentId = context . params . documentId ;
70+ const testId = context . params . testId ;
8071 try {
8172 await admin
8273 . firestore ( )
8374 . collection ( "firestoreDocumentOnWriteTests" )
84- . doc ( documentId )
75+ . doc ( testId )
8576 . set ( sanitizeData ( context ) ) ;
8677 } catch ( error ) {
87- console . error (
88- `Error in Firestore document onWrite function for testId: ${ documentId } ` ,
89- error
90- ) ;
78+ console . error ( `Error in Firestore document onWrite function for testId: ${ testId } ` , error ) ;
9179 }
9280 } ) ;
0 commit comments