Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated README to show the new count method

  • Loading branch information...
commit a995f1d880bb991e7179360a3180aa206100a062 1 parent 11b4fb6
@visoft authored
Showing with 14 additions and 2 deletions.
  1. +9 −1 README.md
  2. +5 −1 test/usage_samples/querying.rb
View
10 README.md
@@ -186,11 +186,19 @@ Top allows you only retrieve the top X number of records when querying. This is
products = svc.execute # => returns only the first 5 items
### Navigation Property Links Only Query
-OData allows you to [query navigation properties and only return the links for the entities](http://www.odata.org/developers/protocols/uri-conventions#AddressingLinksBetweenEntries) (instead of the data)
+OData allows you to [query navigation properties and only return the links for the entities](http://www.odata.org/developers/protocols/uri-conventions#AddressingLinksBetweenEntries) (instead of the data).
+**Note**: You cannot use the `links` method and the `count` method in the same query
svc.Categories(1).links("Products")
product_links = svc.execute # => returns URIs for the products under the Category with an ID of 1
+### Count
+Sometimes all you want to do is count records, for that, you can use the `count` method.
+This method can be combined with other options, such as `filter` but cannot be combined with the `links` method.
+
+ svc.Products.count
+ puts svc.execute # => 2
+
### Partial feeds
OData allows services to do server-side paging in Atom by defining a next link. The default behavior is to repeatedly consume partial feeds until the result set is complete.
View
6 test/usage_samples/querying.rb
@@ -8,7 +8,11 @@
puts "Querying for a list of data"
svc.Categories
categories = svc.execute
-puts categories.to_json
+puts categories.to_json
+
+puts "Querying for a simple count"
+svc.Categories.count
+puts svc.execute
puts "\n\nQuerying for a single result #execute"
svc.Categories(1)
Please sign in to comment.
Something went wrong with that request. Please try again.