lib/google/cloud/datastore.rb in google-cloud-datastore-0.21.0 vs lib/google/cloud/datastore.rb in google-cloud-datastore-0.23.0

- old
+ new

@@ -221,10 +221,14 @@ # the directory structure of a file system. When you create an entity, you # can optionally designate another entity as its parent; the new entity is a # child of the parent entity. # # ```ruby + # require "google/cloud/datastore" + # + # datastore = Google::Cloud::Datastore.new + # # task_key = datastore.key "Task", "sampleTask" # task_key.parent = datastore.key "TaskList", "default" # # task = datastore.entity task_key do |t| # t["type"] = "Personal" @@ -364,10 +368,14 @@ # # The special entity kind `__namespace__` can be used to find all the # namespaces used in your application entities. # # ```ruby + # require "google/cloud/datastore" + # + # datastore = Google::Cloud::Datastore.new + # # query = datastore.query("__namespace__"). # select("__key__"). # where("__key__", ">=", datastore.key("__namespace__", "g")). # where("__key__", "<", datastore.key("__namespace__", "h")) # @@ -378,10 +386,14 @@ # # The special entity kind `__kind__` can be used to return all the # kinds used in your application. # # ```ruby + # require "google/cloud/datastore" + # + # datastore = Google::Cloud::Datastore.new + # # query = datastore.query("__kind__"). # select("__key__") # # kinds = datastore.run(query).map do |entity| # entity.key.name @@ -391,10 +403,14 @@ # Property queries return entities of kind `__property__` denoting the # indexed properties associated with an entity kind. (Unindexed properties # are not included.) # # ```ruby + # require "google/cloud/datastore" + # + # datastore = Google::Cloud::Datastore.new + # # query = datastore.query("__property__"). # select("__key__") # # entities = datastore.run(query) # properties_by_kind = entities.each_with_object({}) do |entity, memo| @@ -410,10 +426,14 @@ # property. The `property_representation` property in the entity # representing property `p` of kind `k` is an array containing all # representations of `p`'s value in any entity of kind `k`. # # ```ruby + # require "google/cloud/datastore" + # + # datastore = Google::Cloud::Datastore.new + # # ancestor_key = datastore.key "__kind__", "Task" # query = datastore.query("__property__"). # ancestor(ancestor_key) # # entities = datastore.run(query) @@ -427,9 +447,13 @@ # Property queries can also be filtered with a range over the # pseudo-property `__key__`, where the keys denote either `__kind__` or # `__property__` entities. # # ```ruby + # require "google/cloud/datastore" + # + # datastore = Google::Cloud::Datastore.new + # # start_key = datastore.key "__property__", "priority" # start_key.parent = datastore.key "__kind__", "Task" # query = datastore.query("__property__"). # select("__key__"). # where("__key__", ">=", start_key)