@@ -86,7 +86,10 @@ function RestWrite(config, auth, className, query, data, originalData, clientSDK
86
86
// Shared SchemaController to be reused to reduce the number of loadSchema() calls per request
87
87
// Once set the schemaData should be immutable
88
88
this . validSchemaController = null ;
89
- this . pendingOps = { } ;
89
+ this . pendingOps = {
90
+ operations : null ,
91
+ identifier : null ,
92
+ } ;
90
93
}
91
94
92
95
// A convenient method to perform all the steps of processing the
@@ -227,10 +230,13 @@ RestWrite.prototype.runBeforeSaveTrigger = function () {
227
230
}
228
231
229
232
const { originalObject, updatedObject } = this . buildParseObjects ( ) ;
230
-
233
+ const identifier = updatedObject . _getStateIdentifier ( ) ;
231
234
const stateController = Parse . CoreManager . getObjectStateController ( ) ;
232
- const [ pending ] = stateController . getPendingOps ( updatedObject . _getStateIdentifier ( ) ) ;
233
- this . pendingOps = { ...pending } ;
235
+ const [ pending ] = stateController . getPendingOps ( identifier ) ;
236
+ this . pendingOps = {
237
+ operations : { ...pending } ,
238
+ identifier,
239
+ } ;
234
240
235
241
return Promise . resolve ( )
236
242
. then ( ( ) => {
@@ -1586,7 +1592,7 @@ RestWrite.prototype.runAfterSaveTrigger = function () {
1586
1592
. then ( result => {
1587
1593
const jsonReturned = result && ! result . _toFullJSON ;
1588
1594
if ( jsonReturned ) {
1589
- this . pendingOps = { } ;
1595
+ this . pendingOps . operations = { } ;
1590
1596
this . response . response = result ;
1591
1597
} else {
1592
1598
this . response . response = this . _updateResponseWithData (
@@ -1690,10 +1696,9 @@ RestWrite.prototype.cleanUserAuthData = function () {
1690
1696
} ;
1691
1697
1692
1698
RestWrite . prototype . _updateResponseWithData = function ( response , data ) {
1693
- const { updatedObject } = this . buildParseObjects ( ) ;
1694
1699
const stateController = Parse . CoreManager . getObjectStateController ( ) ;
1695
- const [ pending ] = stateController . getPendingOps ( updatedObject . _getStateIdentifier ( ) ) ;
1696
- for ( const key in this . pendingOps ) {
1700
+ const [ pending ] = stateController . getPendingOps ( this . pendingOps . identifier ) ;
1701
+ for ( const key in this . pendingOps . operations ) {
1697
1702
if ( ! pending [ key ] ) {
1698
1703
data [ key ] = this . originalData ? this . originalData [ key ] : { __op : 'Delete' } ;
1699
1704
this . storage . fieldsChangedByTrigger . push ( key ) ;
0 commit comments