Fix #119: Empty find options for GET requests
This commit is contained in:
33
classes.js
33
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};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user