Merge pull request #120 from GigabyteTheOne/master

Fix #119: Empty find options for GET requests
This commit is contained in:
Fosco Marotto
2016-02-01 10:08:26 -08:00

View File

@@ -10,35 +10,36 @@ var router = new PromiseRouter();
// Returns a promise that resolves to a {response} object.
function handleFind(req) {
var body = Object.assign(req.body, req.query);
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};
});