Fix: context for afterFind (#7078)

* Fix: context for afterFind

* Update CHANGELOG.md

Co-authored-by: Manuel <trezza.m@gmail.com>
This commit is contained in:
dblythy
2020-12-19 00:54:48 +11:00
committed by GitHub
parent 97c3046f3f
commit 41a052c2c3
5 changed files with 60 additions and 10 deletions

View File

@@ -25,7 +25,8 @@ function RestQuery(
restWhere = {},
restOptions = {},
clientSDK,
runAfterFind = true
runAfterFind = true,
context
) {
this.config = config;
this.auth = auth;
@@ -36,6 +37,7 @@ function RestQuery(
this.runAfterFind = runAfterFind;
this.response = null;
this.findOptions = {};
this.context = context || {};
if (!this.auth.isMaster) {
if (this.className == '_Session') {
@@ -222,7 +224,16 @@ RestQuery.prototype.each = function (callback) {
return !finished;
},
async () => {
const query = new RestQuery(config, auth, className, restWhere, restOptions, clientSDK);
const query = new RestQuery(
config,
auth,
className,
restWhere,
restOptions,
clientSDK,
this.runAfterFind,
this.context
);
const { results } = await query.execute();
results.forEach(callback);
finished = results.length < restOptions.limit;
@@ -772,7 +783,8 @@ RestQuery.prototype.runAfterFindTrigger = function () {
this.className,
this.response.results,
this.config,
parseQuery
parseQuery,
this.context
)
.then(results => {
// Ensure we properly set the className back