Method: ActiveModel::Datastore::ClassMethods#all
- Defined in:
- lib/active_model/datastore.rb
#all(options = {}) ⇒ Array<Model>, String
Queries entities from Cloud Datastore by named kind and using the provided options. When a limit option is provided queries up to the limit and returns results with a cursor.
This method may make several API calls until all query results are retrieved. The ‘run` method returns a QueryResults object, which is a special case Array with additional values. QueryResults are returned in batches, and the batch size is determined by the Datastore API. Batch size is not guaranteed. It will be affected by the size of the data being returned, and by other forces such as how distributed and/or consistent the data in Datastore is. Calling `all` on the QueryResults retrieves all results by repeatedly loading #next until #next? returns false. The `all` method returns an enumerator which from_entities iterates on.
Be sure to use as narrow a search criteria as possible. Please use with caution.
or if options was provided:
290 291 292 293 294 295 296 297 298 299 |
# File 'lib/active_model/datastore.rb', line 290 def all( = {}) next_cursor = nil query = build_query() query_results = retry_on_exception { CloudDatastore.dataset.run query } if [:limit] next_cursor = query_results.cursor if query_results.size == [:limit] return from_entities(query_results.all), next_cursor end from_entities(query_results.all) end |