@function collectionResultPost

execute any collection post functions and return results

@param {object} context

@returns {Promise}
348182
function collectionResultPost (context) {
    // if there are synchronous views then execute any post functions
    if (this.hasCollectionSynchronous) {
        _.each(this.modelViews.collection.synchronous, modelView => {
            // if view does not have post function do nothing
            if (!modelView.post) {
                return
            }
            // execute post function and merge result to context
            _.merge(context, modelView.post(context))
        })
    }
    // if there are asynchronous views then execute any post functions
    if (this.hasCollectionAsynchronous) {
        return Promise.all(_.map(this.modelViews.collection.asynchronous, modelView => {
            // if view does not have post function do nothing
            if (!modelView.post) {
                return
            }
            // execute post function
            return modelView.post({
                context: context,
                session: this.query.session,
            }).then(ctx => {
                _.merge(context, ctx)
            })
        }))
        // resolve with context
        .then(() => context)
    }
    // otherwise resolve with context
    else {
        return Promise.resolve(context)
    }
}
252416
function create(context) {
    return {
        ReturnStatement(node) {
            if (isCommonJsWrapper(nearestFunction(node).parent)) {
                context.report(node, message);
            }
        }
    };
}
533728
function result () {
    // wait for all queries to complete then build result
    return this.promise.then(results => {
        // if the entire result set is a cached view then skip processing
        if (results._cachedView) {
            // result is from collection view
            if (this.modelViewEngine.hasCollection) {
                return results
            }
            // result is record(s)
            else {
                return this.resultRaw(results)
            }
        }
        // order results if needed
        if (results.length > 1) {
            results = this.orderResults(results)
        }
        // if there are model views then build result with ModelViewEngine
        // otherwise build result based on raw data
        return defined(this.modelViewEngine)
            ? this.resultModelView(results)
            : this.resultRaw(results)
    })
}
956602
function create(context) {
    return {
        CallExpression(node) {
            if (isRequireCall(node) && ancestor(isConditional, node)) {
                context.report(node, message);
            }
        }
    };
}
919622
@Override
	public Element execute(Context context) {
		Element result = Undef.VALUE;
		for (Operation op : ops) {
			try {
				result = op.execute(context);
			} catch (EvaluationException ee) {
				throw ee.addExceptionInfo(sourceRange, context);
			}
		}
		return result;
	}
688674
async function compileContext(target, contextOptions) {
	const context = await getContext(target, contextOptions)

	return async function (data/** @param {object} */) {
		return context.map(data)
	}
}
809614
function get(sl, context) {
    var data = parse(sl);
    var result = find(data, context || doc);
    return result;
  }
605115
function fetchRowsFromResult(options, statement, context)
{
  var numInterrupts = 0;

  // forward to the result to get a FetchRowsOperation object
  var operation = context.result.fetchRows(options);

  // subscribe to the operation's 'complete' event
  operation.on('complete', function(err, continueCallback)
  {
    // we want to retry if the error is retryable and the
    // result stream hasn't been closed too many times
    if (Errors.isLargeResultSetError(err) && err.response &&
        (err.response.statusCode === 403) &&
        (numInterrupts <
        context.connectionConfig.getResultStreamInterrupts()))
    {
      // increment the interrupt counter
      numInterrupts++;

      // issue a request to fetch the result again
      sendRequestPostExec(context, function(err, body)
      {
        // refresh the result
        context.onStatementRequestComp(err, body);

        // if there was no error, continue from where we got interrupted
        if (!err)
        {
          continueCallback();
        }
      });
    }
    else
    {
      endFetchRows(options, statement, context);
    }
  });
}
294496
function execute(req, res) {
  var scanner = new Scanner(
    req.db.getKeys(), req.info.cursor, req.info.pattern, req.info.count);
  scanner.scan(req, res);
}
390396
function (context, callback, checkParents) {
            if (this.$parentResource) {
                var self = this;
                flow()
                    .seq("parentCollection", function (cb) {
                        self.$parentResource._findCollection(context, cb);
                    })
                    .seq("parent", function (cb) {
                        var parentCollection = this.vars.parentCollection,
                            id = parentCollection.$modelFactory.prototype.convertIdentifier(self.$parentResource.$resourceId),
                            parent = parentCollection.createItem(id);

                        if (checkParents) {
                            parent.fetch(null, cb);
                        } else {
                            cb(null, parent);
                        }
                    })
                    .exec(function (err, results) {
                        if (!err) {
                            var collection = results.parent.getCollection(self.$resourceConfiguration.$.path);
                            callback && callback(null, collection);
                        } else {
                            callback && callback(err);
                        }
                    });
            } else {
                var dataSource = this.$restHandler.getDataSource(context, this);
                callback && callback(null, dataSource.createCollection(Collection.of(this._getModelFactory()), {pageSize: 100}));
            }
        }
927334
function handleGetRequest(request) {
  const objId = request.objectId;
  const className = request.className;
  if (objId) {
    // Object.fetch() query
    const collection = getCollection(className);
    const currentObject = collection[objId];
    if (!currentObject) {
      return Parse.Promise.as(respond(404, {
        code: 101,
        error: 'object not found for update',
      }));
    }
    let match = _.cloneDeep(currentObject);

    if (match) {
      const toOmit = Array.from(getMask(className));
      match = _.omit(match, toOmit);
    }

    return Parse.Promise.as(respond(200, match));
  }
  const data = request.data;
  indirect = data.redirectClassNameForKey;
  let matches = recursivelyMatch(className, data.where);
  let matchesClassName = '';
  if (indirect) {
    matches = outOfBandResults.matches;
    if (outOfBandResults.className) {
      matchesClassName = outOfBandResults.className;
    }
  }

  if (request.data.count) {
    return Parse.Promise.as(respond(200, { count: matches.length }));
  }

  matches = queryMatchesAfterIncluding(matches, data.include);

  const toOmit = Array.from(getMask(className));
  matches = matches.map((match) => _.omit(match, toOmit));

  // TODO: Can we just call toJSON() in order to avoid this?
  matches.forEach(match => {
    if (match.createdAt) {
      match.createdAt = match.createdAt.toJSON();
    }
    if (match.updatedAt) {
      match.updatedAt = match.updatedAt.toJSON();
    }
  });

  // sort results if necessary
  if (data.order && data.order.length > 0 && matches.length > 0) {
    matches = sortQueryresults(matches, data.order);
  }

  const limit = data.limit || DEFAULT_LIMIT;
  const startIndex = data.skip || 0;
  const endIndex = startIndex + limit;
  const response = { results: matches.slice(startIndex, endIndex) };

  // Add the class name for the outgoing objects to the response if sepcified
  if (matchesClassName.length > 0) {
    response.className = matchesClassName;
  }

  return Parse.Promise.as(respond(200, response));
}
148680
function (query, options) {
            options.$itemsCount = undefined;

            var collection = new this.factory(null, options);
            collection.$context = this.$context;

            return collection;
        }
1354873
function _each (result, callback, context, recordNum, resolve, reject) {
    // fetch more records
    result.fetch()
    // iterate over fetched records
    .then(records => {
        if (!records || !records.length) {
            return
        }
        // iterate over records
        return Promise.each(records, record => {
            // wait for callback to complete if it returns promise
            return callback(record, recordNum++, context)
        })
    })
    .then(() => {
        // resolve parent promise if done
        if (result.done) {
            resolve(context)
        }
        // iterate over more records if not all fetched
        else {
            _each(result, callback, context, recordNum, resolve, reject)
        }
    })
    // pass errors to parent promise
    .catch(reject)
}
558402
function applyModelViewCollectionAsynchronous (context, num, raw) {
    // get data column
    var dataColumn = this.query.model.columnName('data')
    // apply model views to data
    return Promise.all(_.map(this.modelViews.collection.asynchronous, modelView => {
        // if this model view applies to meta data then pass entire db record
        var data = modelView.meta ? raw : raw[dataColumn]
        // call each function with modelView and data
        return modelView.each({
            context: context,
            modelView: modelView,
            number: num,
            record: data,
            session: this.query.session,
        })
        // merge result to data
        .then((eachContext => {
            _.merge(context, eachContext)
        }))
    }))
    // resolve with merged context
    .then(() => context)
}
1342394
function () {
      var self = this;
      return function () {
        var status = self.statusCode;
        
        if (status === 0 || (status >= 400 && status < 600)) {
          return context.asRejectedPromise(self);
        }
        
        return context.asPromise(self);
      };
    }
415895
async function _evaluateContexts(contexts = []) {
  const c = Array.isArray(contexts) ? contexts : [contexts]
  const ep = c.map(evaluateContext)
  const res = await Promise.all(ep)
  return res
}
1153007
function fetchResults (searchText) {
    var items = $scope.$parent.$eval(itemExpr),
        term  = searchText.toLowerCase(),
        isList = angular.isArray(items),
        isPromise = !!items.then; // Every promise should contain a `then` property

    if (isList) onResultsRetrieved(items);
    else if (isPromise) handleAsyncResults(items);

    function handleAsyncResults(items) {
      if (!items) return;

      items = $q.when(items);
      fetchesInProgress++;
      setLoading(true);

      $mdUtil.nextTick(function () {
          items
            .then(onResultsRetrieved)
            .finally(function(){
              if (--fetchesInProgress === 0) {
                setLoading(false);
              }
            });
      },true, $scope);
    }

    function onResultsRetrieved(matches) {
      cache[term] = matches;

      // Just cache the results if the request is now outdated.
      // The request becomes outdated, when the new searchText has changed during the result fetching.
      if ((searchText || '') !== ($scope.searchText || '')) {
        return;
      }

      handleResults(matches);
    }
  }