@@ -158,29 +158,34 @@ DatabaseController.prototype.update = function(className, query, update, {
158
158
159
159
var isMaster = acl === undefined ;
160
160
var aclGroup = acl || [ ] ;
161
- var mongoUpdate , schema ;
161
+ var mongoUpdate ;
162
162
return this . loadSchema ( )
163
- . then ( s => {
164
- schema = s ;
165
- if ( ! isMaster ) {
166
- return schema . validatePermission ( className , aclGroup , 'update' ) ;
167
- }
168
- return Promise . resolve ( ) ;
169
- } )
163
+ . then ( schemaController => {
164
+ return ( isMaster ? Promise . resolve ( ) : schemaController . validatePermission ( className , aclGroup , 'update' ) )
170
165
. then ( ( ) => this . handleRelationUpdates ( className , query . objectId , update ) )
171
166
. then ( ( ) => this . adapter . adaptiveCollection ( className ) )
172
167
. then ( collection => {
173
168
if ( ! isMaster ) {
174
- query = this . addPointerPermissions ( schema , className , 'update' , query , aclGroup ) ;
169
+ query = this . addPointerPermissions ( schemaController , className , 'update' , query , aclGroup ) ;
175
170
}
176
171
if ( ! query ) {
177
172
return Promise . resolve ( ) ;
178
173
}
179
174
if ( acl ) {
180
175
query = addWriteACL ( query , acl ) ;
181
176
}
182
- var mongoWhere = this . transform . transformWhere ( schema , className , query , { validate : ! this . skipValidation } ) ;
183
- mongoUpdate = this . transform . transformUpdate ( schema , className , update , { validate : ! this . skipValidation } ) ;
177
+ var mongoWhere = this . transform . transformWhere (
178
+ schemaController ,
179
+ className ,
180
+ query ,
181
+ { validate : ! this . skipValidation }
182
+ ) ;
183
+ mongoUpdate = this . transform . transformUpdate (
184
+ schemaController ,
185
+ className ,
186
+ update ,
187
+ { validate : ! this . skipValidation }
188
+ ) ;
184
189
if ( many ) {
185
190
return collection . updateMany ( mongoWhere , mongoUpdate ) ;
186
191
} else if ( upsert ) {
@@ -191,14 +196,14 @@ DatabaseController.prototype.update = function(className, query, update, {
191
196
} )
192
197
. then ( result => {
193
198
if ( ! result ) {
194
- return Promise . reject ( new Parse . Error ( Parse . Error . OBJECT_NOT_FOUND ,
195
- 'Object not found.' ) ) ;
199
+ return Promise . reject ( new Parse . Error ( Parse . Error . OBJECT_NOT_FOUND , 'Object not found.' ) ) ;
196
200
}
197
201
if ( this . skipValidation ) {
198
202
return Promise . resolve ( result ) ;
199
203
}
200
204
return sanitizeDatabaseResult ( originalUpdate , result ) ;
201
205
} ) ;
206
+ } ) ;
202
207
} ;
203
208
204
209
function sanitizeDatabaseResult ( originalObject , result ) {
0 commit comments