( triggerType, className, restWhere, restOptions, config, auth, context, isGet )
| 565 | } |
| 566 | |
| 567 | export function maybeRunQueryTrigger( |
| 568 | triggerType, |
| 569 | className, |
| 570 | restWhere, |
| 571 | restOptions, |
| 572 | config, |
| 573 | auth, |
| 574 | context, |
| 575 | isGet |
| 576 | ) { |
| 577 | const trigger = getTrigger(className, triggerType, config.applicationId); |
| 578 | if (!trigger) { |
| 579 | return Promise.resolve({ |
| 580 | restWhere, |
| 581 | restOptions, |
| 582 | }); |
| 583 | } |
| 584 | const json = Object.assign({}, restOptions); |
| 585 | json.where = restWhere; |
| 586 | |
| 587 | const parseQuery = new Parse.Query(className); |
| 588 | parseQuery.withJSON(json); |
| 589 | |
| 590 | let count = false; |
| 591 | if (restOptions) { |
| 592 | count = !!restOptions.count; |
| 593 | } |
| 594 | const requestObject = getRequestQueryObject( |
| 595 | triggerType, |
| 596 | auth, |
| 597 | parseQuery, |
| 598 | count, |
| 599 | config, |
| 600 | context, |
| 601 | isGet |
| 602 | ); |
| 603 | return Promise.resolve() |
| 604 | .then(() => { |
| 605 | return maybeRunValidator(requestObject, `${triggerType}.${className}`, auth); |
| 606 | }) |
| 607 | .then(() => { |
| 608 | if (requestObject.skipWithMasterKey) { |
| 609 | return requestObject.query; |
| 610 | } |
| 611 | return trigger(requestObject); |
| 612 | }) |
| 613 | .then( |
| 614 | result => { |
| 615 | let queryResult = parseQuery; |
| 616 | if (result && result instanceof Parse.Query) { |
| 617 | queryResult = result; |
| 618 | } |
| 619 | const jsonQuery = queryResult.toJSON(); |
| 620 | if (jsonQuery.where) { |
| 621 | restWhere = jsonQuery.where; |
| 622 | } |
| 623 | if (jsonQuery.limit) { |
| 624 | restOptions = restOptions || {}; |
nothing calls this directly
no test coverage detected