Gcloud::Datastore::Query

Query ↑

Represents the search criteria against a Datastore.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  where("completed", "=", true)

entities = dataset.run query

Methods

Public Class Methods

new() ↑

Returns a new query object.

query = Gcloud::Datastore::Query.new

Public Instance Methods

ancestor(parent) ↑

Add a filter for entities that inherit from a key.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  ancestor(parent.key)

completed_tasks = dataset.run query

cursor(cursor) ↑

Alias for: start

filter(name, operator, value) ↑

Alias for: where

group_by(*names) ↑

Group results by a list of properties.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  group_by("completed")

grouped_tasks = dataset.run query

kind(*kinds) ↑

Add the kind of entities to query.

query = Gcloud::Datastore::Query.new
query.kind "Task"

all_tasks = dataset.run query

limit(num) ↑

Set a limit on the number of results to be returned.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  limit(10)

paginated_tasks = dataset.run query

offset(num) ↑

Set an offset for the results to be returned.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  limit(10).
  offset(20)

paginated_tasks = dataset.run query

order(name, direction = :asc) ↑

Sort the results by a property name. By default, an ascending sort order will be used. To sort in descending order, provide a second argument of a string or symbol that starts with ā€œdā€.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  order("due", :desc)

sorted_tasks = dataset.run query

projection(*names) ↑

Alias for: select

select(*names) ↑

Retrieve only select properties from the matched entities.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  select("completed", "due")

partial_tasks = dataset.run query
Also aliased as: projection

start(cursor) ↑

Set the cursor to start the results at.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  limit(10).
  cursor(task_cursor)

paginated_tasks = dataset.run query
Also aliased as: cursor

where(name, operator, value) ↑

Add a property filter to the query.

query = Gcloud::Datastore::Query.new
query.kind("Task").
  where("completed", "=", true)

completed_tasks = dataset.run query
Also aliased as: filter