MCPcopy Index your code
hub / github.com/parse-community/parse-server / maybeRunQueryTrigger

Function maybeRunQueryTrigger

src/triggers.js:567–694  ·  view source on GitHub ↗
(
  triggerType,
  className,
  restWhere,
  restOptions,
  config,
  auth,
  context,
  isGet
)

Source from the content-addressed store, hash-verified

565}
566
567export 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 || {};

Callers

nothing calls this directly

Calls 4

getTriggerFunction · 0.85
getRequestQueryObjectFunction · 0.85
maybeRunValidatorFunction · 0.85
resolveErrorFunction · 0.85

Tested by

no test coverage detected