Skip to content

Instantly share code, notes, and snippets.

@motiooon
Created July 2, 2014 02:41
Show Gist options
  • Save motiooon/3a44b092d5c5318891b7 to your computer and use it in GitHub Desktop.
Save motiooon/3a44b092d5c5318891b7 to your computer and use it in GitHub Desktop.
Loopback Helpers
function lbPick (a){
var str = '';
a.forEach(function(field){
str+='&filter[fields]['+field+']=1';
});
return str;
}
function lbGetPage(page){
var str = '&filter[limit]=50&filter[skip]=' + ((page-1) * 50);
return str;
}
function lbKeywords(a){
var str = '';
a.forEach(function(key){
str+='&filter[where][keywords][inq]='+ key;
});
return str;
}
function lbObjKeywords(a){
var filter={"where": {"keywords": {"inq": a}}};
return '&filter=' + JSON.stringify(filter);
}
module.exports = {
lbPick: lbPick,
lbGetPage:lbGetPage,
lbKeywords:lbKeywords,
lbObjKeywords: lbObjKeywords
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment