@@ -84,10 +84,7 @@ function RestWrite(config, auth, className, query, data, originalData, clientSDK
84
84
// Shared SchemaController to be reused to reduce the number of loadSchema() calls per request
85
85
// Once set the schemaData should be immutable
86
86
this . validSchemaController = null ;
87
- this . pendingOps = {
88
- operations : null ,
89
- identifier : null ,
90
- } ;
87
+ this . pendingOps = { } ;
91
88
}
92
89
93
90
// A convenient method to perform all the steps of processing the
@@ -236,13 +233,10 @@ RestWrite.prototype.runBeforeSaveTrigger = function () {
236
233
}
237
234
238
235
const { originalObject, updatedObject } = this . buildParseObjects ( ) ;
239
- const identifier = updatedObject . _getStateIdentifier ( ) ;
236
+
240
237
const stateController = Parse . CoreManager . getObjectStateController ( ) ;
241
- const [ pending ] = stateController . getPendingOps ( identifier ) ;
242
- this . pendingOps = {
243
- operations : { ...pending } ,
244
- identifier,
245
- } ;
238
+ const [ pending ] = stateController . getPendingOps ( updatedObject . _getStateIdentifier ( ) ) ;
239
+ this . pendingOps = { ...pending } ;
246
240
247
241
return Promise . resolve ( )
248
242
. then ( ( ) => {
@@ -1674,11 +1668,11 @@ RestWrite.prototype.runAfterSaveTrigger = function () {
1674
1668
. then ( result => {
1675
1669
const jsonReturned = result && ! result . _toFullJSON ;
1676
1670
if ( jsonReturned ) {
1677
- this . pendingOps . operations = { } ;
1671
+ this . pendingOps = { } ;
1678
1672
this . response . response = result ;
1679
1673
} else {
1680
1674
this . response . response = this . _updateResponseWithData (
1681
- ( result || updatedObject ) . toJSON ( ) ,
1675
+ ( result || updatedObject ) . _toFullJSON ( ) ,
1682
1676
this . data
1683
1677
) ;
1684
1678
}
@@ -1778,35 +1772,15 @@ RestWrite.prototype.cleanUserAuthData = function () {
1778
1772
} ;
1779
1773
1780
1774
RestWrite . prototype . _updateResponseWithData = function ( response , data ) {
1775
+ const { updatedObject } = this . buildParseObjects ( ) ;
1781
1776
const stateController = Parse . CoreManager . getObjectStateController ( ) ;
1782
- const [ pending ] = stateController . getPendingOps ( this . pendingOps . identifier ) ;
1783
- for ( const key in this . pendingOps . operations ) {
1777
+ const [ pending ] = stateController . getPendingOps ( updatedObject . _getStateIdentifier ( ) ) ;
1778
+ for ( const key in this . pendingOps ) {
1784
1779
if ( ! pending [ key ] ) {
1785
1780
data [ key ] = this . originalData ? this . originalData [ key ] : { __op : 'Delete' } ;
1786
1781
this . storage . fieldsChangedByTrigger . push ( key ) ;
1787
1782
}
1788
1783
}
1789
- const skipKeys = [ ...( requiredColumns . read [ this . className ] || [ ] ) ] ;
1790
- if ( ! this . query ) {
1791
- skipKeys . push ( 'objectId' , 'createdAt' ) ;
1792
- } else {
1793
- skipKeys . push ( 'updatedAt' ) ;
1794
- delete response . objectId ;
1795
- }
1796
- for ( const key in response ) {
1797
- if ( skipKeys . includes ( key ) ) {
1798
- continue ;
1799
- }
1800
- const value = response [ key ] ;
1801
- if (
1802
- value == null ||
1803
- ( value . __type && value . __type === 'Pointer' ) ||
1804
- util . isDeepStrictEqual ( data [ key ] , value ) ||
1805
- util . isDeepStrictEqual ( ( this . originalData || { } ) [ key ] , value )
1806
- ) {
1807
- delete response [ key ] ;
1808
- }
1809
- }
1810
1784
if ( _ . isEmpty ( this . storage . fieldsChangedByTrigger ) ) {
1811
1785
return response ;
1812
1786
}
0 commit comments