@@ -188,7 +188,7 @@ function RestQuery(
188
188
// Returns a promise for the response - an object with optional keys
189
189
// 'results' and 'count'.
190
190
// TODO: consolidate the replaceX functions
191
- RestQuery . prototype . execute = function ( executeOptions ) {
191
+ RestQuery . prototype . execute = function ( executeOptions ) {
192
192
return Promise . resolve ( )
193
193
. then ( ( ) => {
194
194
return this . buildRestWhere ( ) ;
@@ -216,7 +216,7 @@ RestQuery.prototype.execute = function(executeOptions) {
216
216
} ) ;
217
217
} ;
218
218
219
- RestQuery . prototype . each = function ( callback ) {
219
+ RestQuery . prototype . each = function ( callback ) {
220
220
const { config, auth, className, restWhere, restOptions, clientSDK } = this ;
221
221
// if the limit is set, use it
222
222
restOptions . limit = restOptions . limit || 100 ;
@@ -248,7 +248,7 @@ RestQuery.prototype.each = function(callback) {
248
248
) ;
249
249
} ;
250
250
251
- RestQuery . prototype . buildRestWhere = function ( ) {
251
+ RestQuery . prototype . buildRestWhere = function ( ) {
252
252
return Promise . resolve ( )
253
253
. then ( ( ) => {
254
254
return this . getUserAndRoleACL ( ) ;
@@ -277,7 +277,7 @@ RestQuery.prototype.buildRestWhere = function() {
277
277
} ;
278
278
279
279
// Uses the Auth object to get the list of roles, adds the user id
280
- RestQuery . prototype . getUserAndRoleACL = function ( ) {
280
+ RestQuery . prototype . getUserAndRoleACL = function ( ) {
281
281
if ( this . auth . isMaster ) {
282
282
return Promise . resolve ( ) ;
283
283
}
@@ -298,7 +298,7 @@ RestQuery.prototype.getUserAndRoleACL = function() {
298
298
299
299
// Changes the className if redirectClassNameForKey is set.
300
300
// Returns a promise.
301
- RestQuery . prototype . redirectClassNameForKey = function ( ) {
301
+ RestQuery . prototype . redirectClassNameForKey = function ( ) {
302
302
if ( ! this . redirectKey ) {
303
303
return Promise . resolve ( ) ;
304
304
}
@@ -313,7 +313,7 @@ RestQuery.prototype.redirectClassNameForKey = function() {
313
313
} ;
314
314
315
315
// Validates this operation against the allowClientClassCreation config.
316
- RestQuery . prototype . validateClientClassCreation = function ( ) {
316
+ RestQuery . prototype . validateClientClassCreation = function ( ) {
317
317
if (
318
318
this . config . allowClientClassCreation === false &&
319
319
! this . auth . isMaster &&
@@ -358,7 +358,7 @@ function transformInQuery(inQueryObject, className, results) {
358
358
// $inQuery clause.
359
359
// The $inQuery clause turns into an $in with values that are just
360
360
// pointers to the objects returned in the subquery.
361
- RestQuery . prototype . replaceInQuery = function ( ) {
361
+ RestQuery . prototype . replaceInQuery = function ( ) {
362
362
var inQueryObject = findObjectWithKey ( this . restWhere , '$inQuery' ) ;
363
363
if ( ! inQueryObject ) {
364
364
return ;
@@ -419,7 +419,7 @@ function transformNotInQuery(notInQueryObject, className, results) {
419
419
// $notInQuery clause.
420
420
// The $notInQuery clause turns into a $nin with values that are just
421
421
// pointers to the objects returned in the subquery.
422
- RestQuery . prototype . replaceNotInQuery = function ( ) {
422
+ RestQuery . prototype . replaceNotInQuery = function ( ) {
423
423
var notInQueryObject = findObjectWithKey ( this . restWhere , '$notInQuery' ) ;
424
424
if ( ! notInQueryObject ) {
425
425
return ;
@@ -485,7 +485,7 @@ const transformSelect = (selectObject, key, objects) => {
485
485
// The $select clause turns into an $in with values selected out of
486
486
// the subquery.
487
487
// Returns a possible-promise.
488
- RestQuery . prototype . replaceSelect = function ( ) {
488
+ RestQuery . prototype . replaceSelect = function ( ) {
489
489
var selectObject = findObjectWithKey ( this . restWhere , '$select' ) ;
490
490
if ( ! selectObject ) {
491
491
return ;
@@ -550,7 +550,7 @@ const transformDontSelect = (dontSelectObject, key, objects) => {
550
550
// The $dontSelect clause turns into an $nin with values selected out of
551
551
// the subquery.
552
552
// Returns a possible-promise.
553
- RestQuery . prototype . replaceDontSelect = function ( ) {
553
+ RestQuery . prototype . replaceDontSelect = function ( ) {
554
554
var dontSelectObject = findObjectWithKey ( this . restWhere , '$dontSelect' ) ;
555
555
if ( ! dontSelectObject ) {
556
556
return ;
@@ -599,7 +599,7 @@ RestQuery.prototype.replaceDontSelect = function() {
599
599
} ) ;
600
600
} ;
601
601
602
- const cleanResultAuthData = function ( result ) {
602
+ const cleanResultAuthData = function ( result ) {
603
603
delete result . password ;
604
604
if ( result . authData ) {
605
605
Object . keys ( result . authData ) . forEach ( provider => {
@@ -638,7 +638,7 @@ const replaceEqualityConstraint = constraint => {
638
638
return constraint ;
639
639
} ;
640
640
641
- RestQuery . prototype . replaceEquality = function ( ) {
641
+ RestQuery . prototype . replaceEquality = function ( ) {
642
642
if ( typeof this . restWhere !== 'object' ) {
643
643
return ;
644
644
}
@@ -649,7 +649,7 @@ RestQuery.prototype.replaceEquality = function() {
649
649
650
650
// Returns a promise for whether it was successful.
651
651
// Populates this.response with an object that only has 'results'.
652
- RestQuery . prototype . runFind = function ( options = { } ) {
652
+ RestQuery . prototype . runFind = function ( options = { } ) {
653
653
if ( this . findOptions . limit === 0 ) {
654
654
this . response = { results : [ ] } ;
655
655
return Promise . resolve ( ) ;
@@ -685,7 +685,7 @@ RestQuery.prototype.runFind = function(options = {}) {
685
685
686
686
// Returns a promise for whether it was successful.
687
687
// Populates this.response.count with the count
688
- RestQuery . prototype . runCount = function ( ) {
688
+ RestQuery . prototype . runCount = function ( ) {
689
689
if ( ! this . doCount ) {
690
690
return ;
691
691
}
@@ -700,7 +700,7 @@ RestQuery.prototype.runCount = function() {
700
700
} ;
701
701
702
702
// Augments this.response with all pointers on an object
703
- RestQuery . prototype . handleIncludeAll = function ( ) {
703
+ RestQuery . prototype . handleIncludeAll = function ( ) {
704
704
if ( ! this . includeAll ) {
705
705
return ;
706
706
}
@@ -729,7 +729,7 @@ RestQuery.prototype.handleIncludeAll = function() {
729
729
} ;
730
730
731
731
// Updates property `this.keys` to contain all keys but the ones unselected.
732
- RestQuery . prototype . handleExcludeKeys = function ( ) {
732
+ RestQuery . prototype . handleExcludeKeys = function ( ) {
733
733
if ( ! this . excludeKeys ) {
734
734
return ;
735
735
}
@@ -747,7 +747,7 @@ RestQuery.prototype.handleExcludeKeys = function() {
747
747
} ;
748
748
749
749
// Augments this.response with data at the paths provided in this.include.
750
- RestQuery . prototype . handleInclude = function ( ) {
750
+ RestQuery . prototype . handleInclude = function ( ) {
751
751
if ( this . include . length == 0 ) {
752
752
return ;
753
753
}
@@ -774,7 +774,7 @@ RestQuery.prototype.handleInclude = function() {
774
774
} ;
775
775
776
776
//Returns a promise of a processed set of results
777
- RestQuery . prototype . runAfterFindTrigger = function ( ) {
777
+ RestQuery . prototype . runAfterFindTrigger = function ( ) {
778
778
if ( ! this . response ) {
779
779
return ;
780
780
}
@@ -794,14 +794,20 @@ RestQuery.prototype.runAfterFindTrigger = function() {
794
794
if ( this . findOptions . pipeline || this . findOptions . distinct ) {
795
795
return Promise . resolve ( ) ;
796
796
}
797
+
798
+ const json = Object . assign ( { } , this . restOptions ) ;
799
+ json . where = this . restWhere ;
800
+ const parseQuery = new Parse . Query ( this . className ) ;
801
+ parseQuery . withJSON ( json ) ;
797
802
// Run afterFind trigger and set the new results
798
803
return triggers
799
804
. maybeRunAfterFindTrigger (
800
805
triggers . Types . afterFind ,
801
806
this . auth ,
802
807
this . className ,
803
808
this . response . results ,
804
- this . config
809
+ this . config ,
810
+ parseQuery
805
811
)
806
812
. then ( results => {
807
813
// Ensure we properly set the className back
0 commit comments