I want to do a progress circle using data from a table stored in Backendless.
using codeless all I need to do is create an api to sum all the values from the “percentage” column selecting only the to do’s marked as done in the “status” column
Can you guide me please?
Hi Carlos,
We’d be happy to help. Would you be able to provide an example of a response (as JSON) the API should return? I know this is backwards, but, by doing so, it would be easier for us know exactly what’s you’re looking to get.
Regards,
Mark
Hi Mark!
The final result (response) should be a number, but maybe I am understanding wrongly, do you mean the first result from the table?
If so, ( it is a demo table ) here it is:
[
{
“___jsonclass”: “tareas_programadas”,
“tarea”: “titulo de tarea 3”,
“estatus”: “Si”,
“created”: 1531328021569,
“pieza”: “001”,
“___class”: “tareas_programadas”,
“programa”: “001”,
“porcentaje”: “2”,
“ownerId”: null,
“puntos”: “2”,
“updated”: 1531328107782,
“objectId”: “43443B29-D240-0B46-FF41-41A46B59E600”,
“vence”: 1534309200000
},
{
“___jsonclass”: “tareas_programadas”,
“tarea”: “titulo de tarea 2”,
“estatus”: “Si”,
“created”: 1531231736187,
“pieza”: “001”,
“___class”: “tareas_programadas”,
“programa”: “001”,
“porcentaje”: “2”,
“ownerId”: null,
“puntos”: “1”,
“updated”: 1531327616268,
“objectId”: “75A2F3A2-AD1B-63A0-FF78-D64011906700”,
“vence”: 1531630800000
}
]
Or I might not explained myself clearly (sorry for my bad english)
but from this object, I want to extract the values from column “porcentaje”, add the values and return the number as the api result
Hi Carlos,
if I correctly understand you, you want something like I did on my screenshot:
For each item of your objects list, which has field estatus
equal to Si
, I sum porcentaje
column value and return the sum. Please check it.
WOW!!! Great answers Stanislav! Specially the second one, that is exactly what I needed, now I understand so much better how to use this great tool
There is another use for Load Table Objects’ Properties besides aggregate functions?
Glad to help! Happy coding!
Yes, this prop also references object properties which should be returned with every object. So you can ask Backendless to return only some set of fields for each record.
like a Select in a SQL query?
Similar, we support a subset of SQL, specifically the part that goes after “WHERE” in an SQL statement, that’s why we call it the “whereClause”. You can read about it here: https://backendless.com/docs/rest/doc.html#data_search_with_where_clause