Closed bertt closed 7 years ago
Hmm, I can only see this requirement in the SensorThings documentation:
Req 28 The $count system query option with a value of true specifies that the total count of items within a collection matching the request SHALL be returned along with the result. A $count query option with a value of false (or not specified) hints that the service SHALL not return a count. The service SHALL return an HTTP Status code of 400 Bad Request if a value other than true or false is specified. The $count system query option SHALL ignore any $top, $skip, or $expand query options, and SHALL return the total count of results across all pages including only those results matching any specified $filter. Clients should be aware that the count returned inline may not exactly equal the actual number of items returned, due to latency between calculating the count and enumerating the last value or due to inexact calculations on the service.
I think thats about using count in url query part:
Return the result with count
$ curl http://localhost:8080/v1.0/Things?$count=true
Return the result without count
$ curl http://localhost:8080/v1.0/Things?$count=false
that works allright, but when using $count in path it should return only the number.
Yup you're right, I think it's not a requirement but looks useful. Let's implement it
Also according to the SensorThings specification: The $count system query option with a value of true specifies that the total count of items within a collection matching the request SHALL be returned along with the result. A $count query option with a value of false (or not specified) hints that the service SHALL not return a count.
At the moment the count will be returned by default by the GOST server, going to change this to default not returning. This will also save an extra query when $count is not supplied by the user.
@iot.count is not returned by default anymore when requesting a collection. url/$count now returns the raw value of the number of items in a collection, returns 400 if count is not available for endpoint.
tested:
Improve result of $count operator, sample other OData feed: http://services.odata.org/AdventureWorksV3/AdventureWorks.svc/CompanySales/$count
Sample:
actual result:
expected: