@@ -48,7 +48,6 @@ import {
48
48
Query ,
49
49
query ,
50
50
QuerySnapshot ,
51
- runTransaction ,
52
51
setDoc ,
53
52
startAfter ,
54
53
startAt ,
@@ -2096,16 +2095,16 @@ apiDescribe('Queries', persistence => {
2096
2095
expect ( snapshot1 . size , 'snapshot1.size' ) . to . equal ( 100 ) ;
2097
2096
const createdDocuments = snapshot1 . docs . map ( snapshot => snapshot . ref ) ;
2098
2097
2099
- // Delete 50 of the 100 documents. Do this in a transaction , rather than
2098
+ // Delete 50 of the 100 documents. Use a WriteBatch , rather than
2100
2099
// deleteDoc(), to avoid affecting the local cache.
2101
2100
const deletedDocumentIds = new Set < string > ( ) ;
2102
- await runTransaction ( db , async txn => {
2103
- for ( let i = 0 ; i < createdDocuments . length ; i += 2 ) {
2104
- const documentToDelete = createdDocuments [ i ] ;
2105
- txn . delete ( documentToDelete ) ;
2106
- deletedDocumentIds . add ( documentToDelete . id ) ;
2107
- }
2108
- } ) ;
2101
+ const writeBatchForDocumentDeletes = writeBatch ( db ) ;
2102
+ for ( let i = 0 ; i < createdDocuments . length ; i += 2 ) {
2103
+ const documentToDelete = createdDocuments [ i ] ;
2104
+ writeBatchForDocumentDeletes . delete ( documentToDelete ) ;
2105
+ deletedDocumentIds . add ( documentToDelete . id ) ;
2106
+ }
2107
+ await writeBatchForDocumentDeletes . commit ( ) ;
2109
2108
2110
2109
// Wait for 10 seconds, during which Watch will stop tracking the query
2111
2110
// and will send an existence filter rather than "delete" events when
@@ -2260,19 +2259,11 @@ apiDescribe('Queries', persistence => {
2260
2259
) ;
2261
2260
2262
2261
// Delete one of the documents so that the next call to getDocs() will
2263
- // experience an existence filter mismatch. Do this deletion in a
2264
- // transaction, rather than using deleteDoc(), to avoid affecting the
2265
- // local cache.
2266
- await runTransaction ( db , async txn => {
2267
- const snapshotOfDocumentToDelete = await txn . get (
2268
- doc ( coll , 'DocumentToDelete' )
2269
- ) ;
2270
- expect (
2271
- snapshotOfDocumentToDelete . exists ( ) ,
2272
- 'snapshotOfDocumentToDelete.exists()'
2273
- ) . to . be . true ;
2274
- txn . delete ( snapshotOfDocumentToDelete . ref ) ;
2275
- } ) ;
2262
+ // experience an existence filter mismatch. Use a WriteBatch, rather
2263
+ // than deleteDoc(), to avoid affecting the local cache.
2264
+ const writeBatchForDocumentDeletes = writeBatch ( db ) ;
2265
+ writeBatchForDocumentDeletes . delete ( doc ( coll , 'DocumentToDelete' ) ) ;
2266
+ await writeBatchForDocumentDeletes . commit ( ) ;
2276
2267
2277
2268
// Wait for 10 seconds, during which Watch will stop tracking the query
2278
2269
// and will send an existence filter rather than "delete" events when
0 commit comments