Skip to content

Commit 7064f1d

Browse files
Allow queries on specific objects to user the include and keys query parameters.
1 parent b2819df commit 7064f1d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Routers/ClassesRouter.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,24 @@ export class ClassesRouter extends PromiseRouter {
5959

6060
// Returns a promise for a {response} object.
6161
handleGet(req) {
62-
return rest.find(req.config, req.auth, req.params.className, {objectId: req.params.objectId})
62+
let body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
63+
let options = {};
64+
let allowConstraints = ['keys', 'include'];
65+
66+
for (let key of Object.keys(body)) {
67+
if (allowConstraints.indexOf(key) === -1) {
68+
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Improper encode of parameter');
69+
}
70+
}
71+
72+
if (typeof body.keys == 'string') {
73+
options.keys = body.keys;
74+
}
75+
if (body.include) {
76+
options.include = String(body.include);
77+
}
78+
79+
return rest.find(req.config, req.auth, req.params.className, {objectId: req.params.objectId}, options)
6380
.then((response) => {
6481
if (!response.results || response.results.length == 0) {
6582
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Object not found.');

0 commit comments

Comments
 (0)