Create a Total from database items
Thank you. This worked perfectly and I was able to solve my problem
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Thank you. This worked perfectly and I was able to solve my problem
I tried the server code above and it works.
May I know how to filter the amount rather than get the total value of all entry it will filter the value inputed by specific userID. Thank you.
Hello Lonlon!
Please look here: http://devcenter.appery.io/documentat...
Here you will find information, that you need.
Hi Arina,
Is it for server code? Do you have sample code like what Maryna Brodina gave.
Thank you.
Hello Lonlon,
Please read more about passing parameters to the script for Get method here http://devcenter.appery.io/documentat... (if you want to use Server Code)
Also you can retrieve filtered data with Database Query Service (http://devcenter.appery.io/documentat..., you can find more about queries here http://devcenter.appery.io/documentat...)
Hi Arina,
I included additional variable params as a criteria. It works!
var DB_id='xxxxxxxxxxxxxxxxxx',
collectionName='test',
columnName = 'amount',
location = request.get("locationId");
var params = {}; //Define parameters object
params.criteria = { 'location': locationId //Query criteria:
};
try {
query = Collection.query(DB_id, collectionName, params);
var i, len, value, sum = 0;
for(i = 0, len = query.length; i < len; i++) {
value = parseFloat(query[columnName]);
if (value) {
sum += value;
}
}
response.success({totalSum: sum}, "application/json");
} catch (e) {
response.success({message: e.message, code: e.code}, "application/json");
}
Thank you for sharing that ![]()