Futzing with read preference (#3963)
* allow setting readpreference when using rest api. * take out partially complete unit test. * oops. nit * Include read preference option for find directly from api and adding few more tests * Adding catch for all tests * Keep same check for get and find * Turn read preference case insensitive * Includes and subqueries read preferences through API * Fixing bugs regarding changes that were done in master branch during the last year * Changing behavior to make includeReadPreference and subqueryReadPreference to follow readPreference by default
This commit is contained in:
committed by
GitHub
parent
893f1d376e
commit
afa74d655d
@@ -3,7 +3,13 @@ import rest from '../rest';
|
||||
import _ from 'lodash';
|
||||
import Parse from 'parse/node';
|
||||
|
||||
const ALLOWED_GET_QUERY_KEYS = ['keys', 'include'];
|
||||
const ALLOWED_GET_QUERY_KEYS = [
|
||||
'keys',
|
||||
'include',
|
||||
'readPreference',
|
||||
'includeReadPreference',
|
||||
'subqueryReadPreference',
|
||||
];
|
||||
|
||||
export class ClassesRouter extends PromiseRouter {
|
||||
className(req) {
|
||||
@@ -57,12 +63,21 @@ export class ClassesRouter extends PromiseRouter {
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof body.keys == 'string') {
|
||||
if (typeof body.keys === 'string') {
|
||||
options.keys = body.keys;
|
||||
}
|
||||
if (body.include) {
|
||||
options.include = String(body.include);
|
||||
}
|
||||
if (typeof body.readPreference === 'string') {
|
||||
options.readPreference = body.readPreference;
|
||||
}
|
||||
if (typeof body.includeReadPreference === 'string') {
|
||||
options.includeReadPreference = body.includeReadPreference;
|
||||
}
|
||||
if (typeof body.subqueryReadPreference === 'string') {
|
||||
options.subqueryReadPreference = body.subqueryReadPreference;
|
||||
}
|
||||
|
||||
return rest
|
||||
.get(
|
||||
@@ -154,6 +169,9 @@ export class ClassesRouter extends PromiseRouter {
|
||||
'includeAll',
|
||||
'redirectClassNameForKey',
|
||||
'where',
|
||||
'readPreference',
|
||||
'includeReadPreference',
|
||||
'subqueryReadPreference',
|
||||
];
|
||||
|
||||
for (const key of Object.keys(body)) {
|
||||
@@ -188,6 +206,15 @@ export class ClassesRouter extends PromiseRouter {
|
||||
if (body.includeAll) {
|
||||
options.includeAll = true;
|
||||
}
|
||||
if (typeof body.readPreference === 'string') {
|
||||
options.readPreference = body.readPreference;
|
||||
}
|
||||
if (typeof body.includeReadPreference === 'string') {
|
||||
options.includeReadPreference = body.includeReadPreference;
|
||||
}
|
||||
if (typeof body.subqueryReadPreference === 'string') {
|
||||
options.subqueryReadPreference = body.subqueryReadPreference;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user