From 1328270014bb607e4a620dbafd812512472e1436 Mon Sep 17 00:00:00 2001 From: Konstantin Simakov Date: Mon, 1 Feb 2016 12:48:39 +0500 Subject: [PATCH 1/2] Fix #119: Empty find options for GET requests --- classes.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/classes.js b/classes.js index 92d2a220ee..8a2f4624ae 100644 --- a/classes.js +++ b/classes.js @@ -10,35 +10,36 @@ var router = new PromiseRouter(); // Returns a promise that resolves to a {response} object. function handleFind(req) { + var body = req.method === 'GET' ? req.query : req.body; var options = {}; - if (req.body.skip) { - options.skip = Number(req.body.skip); + if (body.skip) { + options.skip = Number(body.skip); } - if (req.body.limit) { - options.limit = Number(req.body.limit); + if (body.limit) { + options.limit = Number(body.limit); } - if (req.body.order) { - options.order = String(req.body.order); + if (body.order) { + options.order = String(body.order); } - if (req.body.count) { + if (body.count) { options.count = true; } - if (typeof req.body.keys == 'string') { - options.keys = req.body.keys; + if (typeof body.keys == 'string') { + options.keys = body.keys; } - if (req.body.include) { - options.include = String(req.body.include); + if (body.include) { + options.include = String(body.include); } - if (req.body.redirectClassNameForKey) { - options.redirectClassNameForKey = String(req.body.redirectClassNameForKey); + if (body.redirectClassNameForKey) { + options.redirectClassNameForKey = String(body.redirectClassNameForKey); } - if(typeof req.body.where === 'string') { - req.body.where = JSON.parse(req.body.where); + if(typeof body.where === 'string') { + body.where = JSON.parse(body.where); } return rest.find(req.config, req.auth, - req.params.className, req.body.where, options) + req.params.className, body.where, options) .then((response) => { return {response: response}; }); From 234c40553003ccac6481760ecad505243926a6c1 Mon Sep 17 00:00:00 2001 From: Konstantin Simakov Date: Mon, 1 Feb 2016 13:36:42 +0500 Subject: [PATCH 2/2] Fix #119: remove 'GET' condition and replace it with assign --- classes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes.js b/classes.js index 8a2f4624ae..dc33eab09f 100644 --- a/classes.js +++ b/classes.js @@ -10,7 +10,7 @@ var router = new PromiseRouter(); // Returns a promise that resolves to a {response} object. function handleFind(req) { - var body = req.method === 'GET' ? req.query : req.body; + var body = Object.assign(req.body, req.query); var options = {}; if (body.skip) { options.skip = Number(body.skip);