rest - Why is aggregation function bad idea for RESTful? -
as title: why aggregation function bad idea restful? although know crud restful.
for example, resource 'employee', , client needs retrive sum of total 'salary' of employees. shouldn't restful service provide such sum function?
further question: if aggregation function bad restful, how can client sum of total salary? retrieve 'employee' records , sum itself?
i wouldn't exposing results of operations (i.e. aggregation function) resources in rest has considered bad.
from restful webservices cookbook (o'reilly):
one of common perceptions of rest’s architectural constraints apply resources “things” or “entities” in application domain. although may true in number of cases, scenarios involve processing functions challenge perception.
it quite common treat processing function resource, , use http fetch representation containing output of processing function. can use query parameters supply inputs processing function.
so why not provide result of salary aggregation of number of employees resource, i.e. this:
get /employees/aggregation?data=salary
or more general:
get /aggregator?resource=employee&data=salary
you filter group of employees salaries should aggregated, i.e. this:
get /employees/aggregation?data=salary&divison=sales
Comments
Post a Comment