adds ability to set hint on Parse.Query #6288 (#6322)

* added hint to aggregate

* added support for hint in query

* added else clause to aggregate

* fixed tests

* updated tests

* Add tests and clean up

* Add support for explain

Co-authored-by: Diamond Lewis <findlewis@gmail.com>
This commit is contained in:
stevestencil
2020-01-14 01:14:43 -07:00
committed by Diamond Lewis
parent 5a1d94ed88
commit 9842c6ee42
9 changed files with 267 additions and 21 deletions

View File

@@ -1289,13 +1289,14 @@ class DatabaseController {
distinct,
pipeline,
readPreference,
hint,
explain,
}: any = {},
auth: any = {},
validSchemaController: SchemaController.SchemaController
): Promise<any> {
const isMaster = acl === undefined;
const aclGroup = acl || [];
op =
op ||
(typeof query.objectId == 'string' && Object.keys(query).length === 1
@@ -1333,7 +1334,15 @@ class DatabaseController {
sort.updatedAt = sort._updated_at;
delete sort._updated_at;
}
const queryOptions = { skip, limit, sort, keys, readPreference };
const queryOptions = {
skip,
limit,
sort,
keys,
readPreference,
hint,
explain,
};
Object.keys(sort).forEach(fieldName => {
if (fieldName.match(/^authData\.([a-zA-Z0-9_]+)\.id$/)) {
throw new Parse.Error(
@@ -1406,7 +1415,9 @@ class DatabaseController {
className,
schema,
query,
readPreference
readPreference,
undefined,
hint
);
}
} else if (distinct) {
@@ -1428,9 +1439,18 @@ class DatabaseController {
className,
schema,
pipeline,
readPreference
readPreference,
hint,
explain
);
}
} else if (explain) {
return this.adapter.find(
className,
schema,
query,
queryOptions
);
} else {
return this.adapter
.find(className, schema, query, queryOptions)