@@ -36,6 +36,8 @@ export default class FirestoreQuery {
36
36
}
37
37
38
38
_handleQueryCursor ( cursor , docOrField , fields ) {
39
+ const modifiers = this . _modifiers . _copy ( ) ;
40
+
39
41
if ( isUndefined ( docOrField ) ) {
40
42
throw new Error (
41
43
`firebase.firestore().collection().${ cursor } (*) Expected a DocumentSnapshot or list of field values but got undefined.` ,
@@ -58,7 +60,7 @@ export default class FirestoreQuery {
58
60
) ;
59
61
}
60
62
61
- const currentOrders = this . _modifiers . orders ;
63
+ const currentOrders = modifiers . orders ;
62
64
63
65
const values = [ ] ;
64
66
@@ -77,14 +79,14 @@ export default class FirestoreQuery {
77
79
values . push ( value ) ;
78
80
}
79
81
80
- this . _modifiers . _orders . push ( {
82
+ modifiers . _orders . push ( {
81
83
fieldPath : '__name__' ,
82
84
direction : 'ASCENDING' ,
83
85
} ) ;
84
86
85
87
values . push ( documentSnapshot . id ) ;
86
88
87
- return this . _modifiers . setFieldsCursor ( cursor , values ) ;
89
+ return modifiers . setFieldsCursor ( cursor , values ) ;
88
90
}
89
91
90
92
/**
@@ -93,13 +95,13 @@ export default class FirestoreQuery {
93
95
94
96
const allFields = [ docOrField ] . concat ( fields ) ;
95
97
96
- if ( allFields . length > this . _modifiers . orders . length ) {
98
+ if ( allFields . length > modifiers . orders . length ) {
97
99
throw new Error (
98
100
`firebase.firestore().collection().${ cursor } (*) Too many arguments provided. The number of arguments must be less than or equal to the number of orderBy() clauses.` ,
99
101
) ;
100
102
}
101
103
102
- return this . _modifiers . setFieldsCursor ( cursor , allFields ) ;
104
+ return modifiers . setFieldsCursor ( cursor , allFields ) ;
103
105
}
104
106
105
107
endAt ( docOrField , ...fields ) {
@@ -187,7 +189,7 @@ export default class FirestoreQuery {
187
189
) ;
188
190
}
189
191
190
- const modifiers = this . _modifiers . limit ( limit ) ;
192
+ const modifiers = this . _modifiers . _copy ( ) . limit ( limit ) ;
191
193
192
194
return new FirestoreQuery ( this . _firestore , this . _collectionPath , modifiers ) ;
193
195
}
@@ -291,7 +293,7 @@ export default class FirestoreQuery {
291
293
) ;
292
294
}
293
295
294
- const modifiers = this . _modifiers . orderBy ( path , directionStr ) ;
296
+ const modifiers = this . _modifiers . _copy ( ) . orderBy ( path , directionStr ) ;
295
297
296
298
try {
297
299
modifiers . validateOrderBy ( ) ;
@@ -355,7 +357,7 @@ export default class FirestoreQuery {
355
357
) ;
356
358
}
357
359
358
- const modifiers = this . _modifiers . where ( path , opStr , value ) ;
360
+ const modifiers = this . _modifiers . _copy ( ) . where ( path , opStr , value ) ;
359
361
360
362
try {
361
363
modifiers . validateWhere ( ) ;
0 commit comments