MCPcopy Create free account
hub / github.com/parse-community/parse-server / handleFind

Method handleFind

src/Routers/AggregateRouter.js:8–80  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

6
7export class AggregateRouter extends ClassesRouter {
8 async handleFind(req) {
9 const body = Object.assign(req.body || {}, ClassesRouter.JSONFromQuery(req.query));
10 const options = {};
11 if (body.distinct) {
12 options.distinct = String(body.distinct);
13 }
14 if (body.hint) {
15 options.hint = body.hint;
16 delete body.hint;
17 }
18 if (body.explain) {
19 options.explain = body.explain;
20 delete body.explain;
21 }
22 if (body.comment) {
23 options.comment = body.comment;
24 delete body.comment;
25 }
26 if (body.readPreference) {
27 options.readPreference = body.readPreference;
28 delete body.readPreference;
29 }
30 if (typeof body.rawValues === 'boolean') {
31 options.rawValues = body.rawValues;
32 delete body.rawValues;
33 }
34 if (typeof body.rawFieldNames === 'boolean') {
35 options.rawFieldNames = body.rawFieldNames;
36 delete body.rawFieldNames;
37 }
38 const queryOptions = (req.config && req.config.query) || {};
39 if (options.rawValues === undefined && typeof queryOptions.aggregationRawValues === 'boolean') {
40 options.rawValues = queryOptions.aggregationRawValues;
41 }
42 if (
43 options.rawFieldNames === undefined &&
44 typeof queryOptions.aggregationRawFieldNames === 'boolean'
45 ) {
46 options.rawFieldNames = queryOptions.aggregationRawFieldNames;
47 }
48 options.pipeline = AggregateRouter.getPipeline(body);
49 if (typeof body.where === 'string') {
50 try {
51 body.where = JSON.parse(body.where);
52 } catch {
53 throw new Parse.Error(Parse.Error.INVALID_JSON, 'where parameter is not valid JSON');
54 }
55 }
56 try {
57 const response = await rest.find(
58 req.config,
59 req.auth,
60 this.className(req),
61 body.where,
62 options,
63 req.info.clientSDK,
64 req.info.context
65 );

Callers 1

mountRoutesMethod · 0.95

Calls 5

JSONFromQueryMethod · 0.80
getPipelineMethod · 0.80
findMethod · 0.65
classNameMethod · 0.45

Tested by

no test coverage detected