Skip to content

Commit

Permalink
Merge pull request #203 from ritishgumber/master
Browse files Browse the repository at this point in the history
Funnel Changes anf defaut sort fix
  • Loading branch information
shubhamqweasd authored Jun 27, 2017
2 parents ed1d393 + 86b9a22 commit c615cb8
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 90 deletions.
10 changes: 0 additions & 10 deletions api/tables/CloudObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ function _getData(req, res) { //get document(s) object based on query and variou
var appKey = req.body.key || req.param('key');
var sdk = req.body.sdk || "REST";

//default sort added
/*
without sort if limit and skip are used, the records are returned out of order. To solve this default sort in ascending order of 'createdAt' is added
*/

if (Object.keys(sort).length === 0 && sort.constructor === Object)
sort = {
createdAt: 1
}

global.appService.isMasterKey(appId, appKey).then(function(isMasterKey) {
return global.customService.find(appId, collectionName, query, select, sort, limit, skip, customHelper.getAccessList(req), isMasterKey);
}).then(function(results) {
Expand Down
7 changes: 7 additions & 0 deletions databases/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ module.exports = function() {
if (!sort) {
sort = {};
}
//default sort added
/*
without sort if limit and skip are used, the records are returned out of order. To solve this default sort in ascending order of 'createdAt' is added
*/

if (!sort['createdAt'])
sort['createdAt'] = 1

if (!limit || limit === -1) {
limit = 20;
Expand Down
115 changes: 100 additions & 15 deletions helpers/cloudTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,97 @@ module.exports = {
"editableByMasterKey": false
}
],
Custom: [
{
_Funnel: [
{
"name": "id",
"_type": "column",
"dataType": "Id",
"required": true,
"unique": true,
"relatedTo": null,
"relationType": null,
"isDeletable": false,
"isEditable": false,
"isRenamable": false,
"editableByMasterKey": false,
"defaultValue": null
}, {
"name": "updatedAt",
"_type": "column",
"dataType": "DateTime",
"required": true,
"unique": false,
"relatedTo": null,
"relationType": null,
"isDeletable": false,
"isEditable": false,
"isRenamable": false,
"editableByMasterKey": false
}, {
"name": "createdAt",
"_type": "column",
"dataType": "DateTime",
"required": true,
"unique": false,
"relatedTo": null,
"relationType": null,
"isDeletable": false,
"isEditable": false,
"isRenamable": false,
"editableByMasterKey": false
}, {
"name": "expires",
"_type": "column",
"dataType": "DateTime",
"required": false,
"unique": false,
"relatedTo": null,
"relationType": null,
"isDeletable": false,
"isEditable": false,
"isRenamable": false,
"editableByMasterKey": false
}, {
"name": "ACL",
"_type": "column",
"dataType": "ACL",
"required": true,
"unique": false,
"relatedTo": null,
"relationType": null,
"isDeletable": false,
"isEditable": false,
"isRenamable": false,
"editableByMasterKey": false
}, {
"name": "name",
"_type": "column",
"dataType": "Text",
"required": true,
"unique": false,
"relatedTo": "Text",
"relationType": null,
"isDeletable": false,
"isEditable": false,
"isRenamable": false,
"editableByMasterKey": false,
"defaultValue": null
}, {
"name": "data",
"_type": "column",
"dataType": "Object",
"required": true,
"unique": false,
"relatedTo": null,
"relationType": null,
"isDeletable": false,
"isEditable": false,
"isRenamable": false,
"editableByMasterKey": false
}
],
Custom: [
{
name: 'id',
_type: 'column',
dataType: 'Id',
Expand All @@ -593,9 +682,8 @@ module.exports = {
isEditable: false,
isRenamable: false,
editableByMasterKey: false,
defaultValue: null
},
{
defaultValue: null
}, {
name: 'expires',
_type: 'column',
dataType: 'DateTime',
Expand All @@ -607,9 +695,8 @@ module.exports = {
isEditable: false,
isRenamable: false,
editableByMasterKey: false,
defaultValue: null
},
{
defaultValue: null
}, {
name: 'updatedAt',
_type: 'column',
dataType: 'DateTime',
Expand All @@ -622,8 +709,7 @@ module.exports = {
isRenamable: false,
editableByMasterKey: false,
defaultValue: null
},
{
}, {
name: 'createdAt',
_type: 'column',
dataType: 'DateTime',
Expand All @@ -635,9 +721,8 @@ module.exports = {
isEditable: false,
isRenamable: false,
editableByMasterKey: false,
defaultValue: null
},
{
defaultValue: null
}, {
name: 'ACL',
_type: 'column',
dataType: 'ACL',
Expand All @@ -650,6 +735,6 @@ module.exports = {
isRenamable: false,
editableByMasterKey: false,
defaultValue: null
}
}
]
};
};
Loading

0 comments on commit c615cb8

Please sign in to comment.