Read preference option per query (#3865)
This commit is contained in:
committed by
Natan Rolnik
parent
422723fa31
commit
b6298feaa7
@@ -88,6 +88,7 @@ function RestQuery(config, auth, className, restWhere = {}, restOptions = {}, cl
|
||||
break;
|
||||
case 'skip':
|
||||
case 'limit':
|
||||
case 'readPreference':
|
||||
this.findOptions[option] = restOptions[option];
|
||||
break;
|
||||
case 'order':
|
||||
@@ -128,6 +129,9 @@ function RestQuery(config, auth, className, restWhere = {}, restOptions = {}, cl
|
||||
this.redirectKey = restOptions.redirectClassNameForKey;
|
||||
this.redirectClassName = null;
|
||||
break;
|
||||
case 'includeReadPreference':
|
||||
case 'subqueryReadPreference':
|
||||
break;
|
||||
default:
|
||||
throw new Parse.Error(Parse.Error.INVALID_JSON,
|
||||
'bad option: ' + option);
|
||||
@@ -260,6 +264,11 @@ RestQuery.prototype.replaceInQuery = function() {
|
||||
redirectClassNameForKey: inQueryValue.redirectClassNameForKey
|
||||
};
|
||||
|
||||
if (this.restOptions.subqueryReadPreference) {
|
||||
additionalOptions.readPreference = this.restOptions.subqueryReadPreference;
|
||||
additionalOptions.subqueryReadPreference = this.restOptions.subqueryReadPreference;
|
||||
}
|
||||
|
||||
var subquery = new RestQuery(
|
||||
this.config, this.auth, inQueryValue.className,
|
||||
inQueryValue.where, additionalOptions);
|
||||
@@ -308,6 +317,11 @@ RestQuery.prototype.replaceNotInQuery = function() {
|
||||
redirectClassNameForKey: notInQueryValue.redirectClassNameForKey
|
||||
};
|
||||
|
||||
if (this.restOptions.subqueryReadPreference) {
|
||||
additionalOptions.readPreference = this.restOptions.subqueryReadPreference;
|
||||
additionalOptions.subqueryReadPreference = this.restOptions.subqueryReadPreference;
|
||||
}
|
||||
|
||||
var subquery = new RestQuery(
|
||||
this.config, this.auth, notInQueryValue.className,
|
||||
notInQueryValue.where, additionalOptions);
|
||||
@@ -358,6 +372,11 @@ RestQuery.prototype.replaceSelect = function() {
|
||||
redirectClassNameForKey: selectValue.query.redirectClassNameForKey
|
||||
};
|
||||
|
||||
if (this.restOptions.subqueryReadPreference) {
|
||||
additionalOptions.readPreference = this.restOptions.subqueryReadPreference;
|
||||
additionalOptions.subqueryReadPreference = this.restOptions.subqueryReadPreference;
|
||||
}
|
||||
|
||||
var subquery = new RestQuery(
|
||||
this.config, this.auth, selectValue.query.className,
|
||||
selectValue.query.where, additionalOptions);
|
||||
@@ -406,6 +425,11 @@ RestQuery.prototype.replaceDontSelect = function() {
|
||||
redirectClassNameForKey: dontSelectValue.query.redirectClassNameForKey
|
||||
};
|
||||
|
||||
if (this.restOptions.subqueryReadPreference) {
|
||||
additionalOptions.readPreference = this.restOptions.subqueryReadPreference;
|
||||
additionalOptions.subqueryReadPreference = this.restOptions.subqueryReadPreference;
|
||||
}
|
||||
|
||||
var subquery = new RestQuery(
|
||||
this.config, this.auth, dontSelectValue.query.className,
|
||||
dontSelectValue.query.where, additionalOptions);
|
||||
@@ -605,6 +629,11 @@ function includePath(config, auth, response, path, restOptions = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
if (restOptions.includeReadPreference) {
|
||||
includeRestOptions.readPreference = restOptions.includeReadPreference;
|
||||
includeRestOptions.includeReadPreference = restOptions.includeReadPreference;
|
||||
}
|
||||
|
||||
const queryPromises = Object.keys(pointersHash).map((className) => {
|
||||
const where = {'objectId': {'$in': Array.from(pointersHash[className])}};
|
||||
var query = new RestQuery(config, auth, className, where, includeRestOptions);
|
||||
|
||||
Reference in New Issue
Block a user