Robert Lamb
Posts: 0
Joined: Sat Jun 04, 2016 4:54 pm

Filter data that is in an array

Deon,

Is it possible to help me solve this, desperate and need to find a solution. Am I being dumb? Fellow South african here ;)

-----------------------------

Distict Values with where clause on column: Server Code

Why am i getting an empty result on this distinct query?

//var getRegion = localStorage.getItem('setRegion');
var getRegion = "CENTRAL";
//console.log (getRegion);

//distinct(dbApiKey, collectionName, columnName[, queryString][, token])
var result = Collection.distinct("xxxxxxxxxx", "Reach", "SalesDistrict",{where:{"Region": "'+getRegion+'"}});
Apperyio.response.success(result, "application/json");

If I remove the where clause it retrieves all the records in the Collection. I want the Distinct values based on the Region.

Currently this gives me a result of []!

-----------------------------------------------
Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Filter data that is in an array

Hi Robert

Glad to see fellow SAFFA using Appery.

I am presuming the following...
Your collection is called "SalesDistrict" and the column "Region" contains the distinct values you want to retrieve.
I am not sure what "Reach" is in your code, unless that is the collection name and SalesDistrict is your col name?

Try this?

var dbApiKey = "xxxxxxx";
var getRegion = "Central";
var result = Collection.distinct(dbApiKey, "SalesDistrict", 'Region', {"Region": "' + getRegion+ '"});

The above should return Central only.

result = Collection.distinct(dbApiKey, "SalesDistrict", "Region");
the above should return all distinct regions.

Let me know if that works for you.

Robert Lamb
Posts: 0
Joined: Sat Jun 04, 2016 4:54 pm

Filter data that is in an array

Deon, any way I can bend your ear over an email?

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Filter data that is in an array

sure thing - a href="mailto:deon@software3.biz" rel="nofollow"deon@software3.biz/a

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Filter data that is in an array

Hi Robert. Drop me an email if you would be interested in working on some projects.
a href="mailto:deon@software3.biz" rel="nofollow"deon@software3.biz/a

Thanks
Deon

Return to “Issues”