Gcloud::Datastore::Key
Key¶ ↑
Every Datastore record has an identifying key, which includes the record's entity kind and a unique identifier. The identifier may be either a key name string, assigned explicitly by the application, or an integer numeric ID, assigned automatically by Datastore.
key = Gcloud::Datastore::Key.new "User", "username"
Parent:
Object
Methods
Attributes
parent
[R]
¶
↑
The parent of the Key.
Returns¶ ↑
Key
or nil
Example¶ ↑
require "gcloud" gcloud = Gcloud.new dataset = gcloud.datastore user = dataset.find "User", "heidi" query = Gcloud::Datastore::Query.new query.kind("List"). ancestor(user.key) lists = dataset.run query lists.first.key.parent #=> Key("User", "heidi")
Public Instance Methods
complete?()
¶
↑
Determine if the key is complete. A complete key has either an id or a name.
Inverse of incomplete?
incomplete?()
¶
↑
Determine if the key is incomplete. An incomplete key has neither an id nor a name.
Inverse of complete?
path()
¶
↑
Represent the Key's path (including parent) as an array of arrays. Each inner array contains two values, the kind and the id or name. If neither an id or name exist then nil will be returned.
Returns¶ ↑
Array of arrays
Example¶ ↑
key = Gcloud::Datastore::Key.new "List", "todos" key.parent = Gcloud::Datastore::Key.new "User", "heidi" key.path #=> [["User", "heidi"], ["List", "todos"]]