Skip to content

Instantly share code, notes, and snippets.

@jgeewax
Created August 27, 2015 17:09
Show Gist options
  • Save jgeewax/c254f8b4d9f48162eaad to your computer and use it in GitHub Desktop.
Save jgeewax/c254f8b4d9f48162eaad to your computer and use it in GitHub Desktop.
{
"document": {
"@source": "/usr/local/google/home/jjg/gcloud-python/docs/datastore-queries.rst",
"section": {
"@ids": "module-gcloud.datastore.query queries",
"@names": "queries",
"title": "Queries",
"index": [
{
"@entries": "['single',\\ u'gcloud.datastore.query\\ (module)',\\ u'module-gcloud.datastore.query',\\ '']"
},
{
"@entries": "['single',\\ u'Iterator\\ (class\\ in\\ gcloud.datastore.query)',\\ u'gcloud.datastore.query.Iterator',\\ '']"
},
{
"@entries": "['single',\\ u'Query\\ (class\\ in\\ gcloud.datastore.query)',\\ u'gcloud.datastore.query.Query',\\ '']"
}
],
"paragraph": "Create / interact with gcloud datastore queries.",
"desc": [
{
"@desctype": "class",
"@domain": "py",
"@noindex": "False",
"@objtype": "class",
"desc_signature": {
"@class": "",
"@first": "False",
"@fullname": "Iterator",
"@ids": "gcloud.datastore.query.Iterator",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Iterator",
"desc_annotation": "class",
"desc_addname": "gcloud.datastore.query.",
"desc_name": "Iterator",
"desc_parameterlist": {
"desc_parameter": [
"query",
"client",
"limit=None",
"offset=0",
"start_cursor=None",
"end_cursor=None"
]
},
"comment": {
"@xml:space": "preserve"
}
},
"desc_content": {
"paragraph": [
{
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/functions.html#object",
"literal": {
"@classes": "xref py py-class",
"#text": "object"
}
},
"#text": "Bases:"
},
"Represent the state of a given execution of a Query."
],
"field_list": {
"field": {
"field_name": "Parameters",
"field_body": {
"bullet_list": {
"list_item": [
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "query"
},
"reference": {
"@internal": "True",
"@refid": "gcloud.datastore.query.Query",
"@reftitle": "gcloud.datastore.query.Query",
"literal": {
"@classes": "xref py py-class",
"#text": "gcloud.datastore.query.Query"
}
},
"#text": "() -- Query object holding permanent configuration (i.e.\nthings that don't change on with each page in\na results set)."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "client"
},
"reference": {
"@internal": "True",
"@reftitle": "gcloud.datastore.client.Client",
"@refuri": "datastore-client#gcloud.datastore.client.Client",
"literal": {
"@classes": "xref py py-class",
"#text": "gcloud.datastore.client.Client"
}
},
"#text": "() -- The client used to make a request."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "limit"
},
"emphasis": "integer",
"#text": "() -- (Optional) Limit the number of results returned."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "offset"
},
"emphasis": "integer",
"#text": "() -- (Optional) Defaults to 0. Offset used to begin\na query."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "start_cursor"
},
"emphasis": "bytes",
"#text": "() -- (Optional) Cursor to begin paging through\nquery results."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "end_cursor"
},
"emphasis": "bytes",
"#text": "() -- (Optional) Cursor to end paging through\nquery results."
}
}
]
}
}
}
},
"index": {
"@entries": "['single',\\ u'next_page()\\ (gcloud.datastore.query.Iterator\\ method)',\\ u'gcloud.datastore.query.Iterator.next_page',\\ '']"
},
"desc": {
"@desctype": "method",
"@domain": "py",
"@noindex": "False",
"@objtype": "method",
"desc_signature": {
"@class": "Iterator",
"@first": "False",
"@fullname": "Iterator.next_page",
"@ids": "gcloud.datastore.query.Iterator.next_page",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Iterator.next_page",
"desc_name": "next_page",
"desc_parameterlist": null,
"comment": {
"@xml:space": "preserve"
}
},
"desc_content": {
"paragraph": [
"Fetch a single \"page\" of query results.",
"Low-level API for fine control: the more convenient API is\nto iterate on the current Iterator."
],
"field_list": {
"field": {
"field_name": "Return type",
"field_body": {
"paragraph": "tuple, (entities, more_results, cursor)"
}
}
}
}
}
}
},
{
"@desctype": "class",
"@domain": "py",
"@noindex": "False",
"@objtype": "class",
"desc_signature": {
"@class": "",
"@first": "False",
"@fullname": "Query",
"@ids": "gcloud.datastore.query.Query",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query",
"desc_annotation": "class",
"desc_addname": "gcloud.datastore.query.",
"desc_name": "Query",
"desc_parameterlist": {
"desc_parameter": [
"client",
"kind=None",
"dataset_id=None",
"namespace=None",
"ancestor=None",
"filters=()",
"projection=()",
"order=()",
"group_by=()"
]
},
"comment": {
"@xml:space": "preserve"
}
},
"desc_content": {
"paragraph": [
{
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/functions.html#object",
"literal": {
"@classes": "xref py py-class",
"#text": "object"
}
},
"#text": "Bases:"
},
"A Query against the Cloud Datastore.",
"This class serves as an abstraction for creating a query over data\nstored in the Cloud Datastore."
],
"field_list": {
"field": [
{
"field_name": "Parameters",
"field_body": {
"bullet_list": {
"list_item": [
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "client"
},
"reference": {
"@internal": "True",
"@reftitle": "gcloud.datastore.client.Client",
"@refuri": "datastore-client#gcloud.datastore.client.Client",
"literal": {
"@classes": "xref py py-class",
"#text": "gcloud.datastore.client.Client"
}
},
"#text": "() -- The client used to connect to datastore."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "kind"
},
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/string.html#module-string",
"emphasis": "string"
},
"#text": "() -- The kind to query."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "dataset_id"
},
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/string.html#module-string",
"emphasis": "string"
},
"#text": "() -- The ID of the dataset to query. If not passed,\nuses the client's value."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "namespace"
},
"emphasis": "string or None",
"#text": "() -- The namespace to which to restrict results. If not\npassed, uses the client's value."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "ancestor"
},
"reference": {
"@internal": "True",
"@reftitle": "gcloud.datastore.key.Key",
"@refuri": "datastore-keys#gcloud.datastore.key.Key",
"literal": {
"@classes": "xref py py-class",
"#text": "gcloud.datastore.key.Key"
}
},
"#text": "( or None) -- key of the ancestor to which this query's results are\nrestricted."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "filters"
},
"emphasis": "sequence of (property_name, operator, value) tuples",
"#text": "() -- property filters applied by this query."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "projection"
},
"emphasis": "sequence of string",
"#text": "() -- fields returned as part of query results."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "order"
},
"emphasis": "sequence of string",
"#text": "() -- field names used to order query results. Prepend '-'\nto a field name to sort it in descending order."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "group_by"
},
"emphasis": "sequence of string",
"#text": "() -- field names used to group query results."
}
}
]
}
}
},
{
"field_name": "Raises",
"field_body": {
"paragraph": {
"literal": "dataset_id",
"#text": "ValueError if is not passed and no implicit\ndefault is set."
}
}
}
]
},
"index": [
{
"@entries": "['single',\\ u'OPERATORS\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.OPERATORS',\\ '']"
},
{
"@entries": "['single',\\ u'add_filter()\\ (gcloud.datastore.query.Query\\ method)',\\ u'gcloud.datastore.query.Query.add_filter',\\ '']"
},
{
"@entries": "['single',\\ u'ancestor\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.ancestor',\\ '']"
},
{
"@entries": "['single',\\ u'dataset_id\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.dataset_id',\\ '']"
},
{
"@entries": "['single',\\ u'fetch()\\ (gcloud.datastore.query.Query\\ method)',\\ u'gcloud.datastore.query.Query.fetch',\\ '']"
},
{
"@entries": "['single',\\ u'filters\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.filters',\\ '']"
},
{
"@entries": "['single',\\ u'group_by\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.group_by',\\ '']"
},
{
"@entries": "['single',\\ u'keys_only()\\ (gcloud.datastore.query.Query\\ method)',\\ u'gcloud.datastore.query.Query.keys_only',\\ '']"
},
{
"@entries": "['single',\\ u'kind\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.kind',\\ '']"
},
{
"@entries": "['single',\\ u'namespace\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.namespace',\\ '']"
},
{
"@entries": "['single',\\ u'order\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.order',\\ '']"
},
{
"@entries": "['single',\\ u'projection\\ (gcloud.datastore.query.Query\\ attribute)',\\ u'gcloud.datastore.query.Query.projection',\\ '']"
}
],
"desc": [
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.OPERATORS",
"@ids": "gcloud.datastore.query.Query.OPERATORS",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.OPERATORS",
"desc_name": "OPERATORS",
"desc_annotation": "= {'=': 5, '<': 1, '>': 3, '<=': 2, '>=': 4}"
},
"desc_content": {
"paragraph": "Mapping of operator strings and their protobuf equivalents."
}
},
{
"@desctype": "method",
"@domain": "py",
"@noindex": "False",
"@objtype": "method",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.add_filter",
"@ids": "gcloud.datastore.query.Query.add_filter",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.add_filter",
"desc_name": "add_filter",
"desc_parameterlist": {
"desc_parameter": [
"property_name",
"operator",
"value"
]
},
"comment": {
"@xml:space": "preserve"
}
},
"desc_content": {
"paragraph": [
"Filter the query based on a property name, operator and a value.",
"Expressions take the form of:",
{
"literal": [
"OPERATORS",
"=",
"<",
"<=",
">",
">="
],
"#text": "where property is a property stored on the entity in the datastore\nand operator is one of \n(ie, , , , , ):"
}
],
"literal_block": [
{
"@xml:space": "preserve",
"#text": ".add_filter('<property>', '<operator>', <value>)"
},
{
"@xml:space": "preserve",
"#text": ">>> from gcloud import datastore\n>>> query = datastore.Query('Person')\n>>> query.add_filter('name', '=', 'James')\n>>> query.add_filter('age', '>', 50)"
}
],
"field_list": {
"field": [
{
"field_name": "Parameters",
"field_body": {
"bullet_list": {
"list_item": [
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "property_name"
},
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/string.html#module-string",
"emphasis": "string"
},
"#text": "() -- A property name."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "operator"
},
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/string.html#module-string",
"emphasis": "string"
},
"literal": [
"=",
"<",
"<=",
">",
">="
],
"#text": "() -- One of , , , , ."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "value"
},
"emphasis": "integer, string, boolean, float, None, datetime",
"#text": "() -- The value to filter on."
}
}
]
}
}
},
{
"field_name": "Raises",
"field_body": {
"paragraph": {
"literal": [
{
"@classes": "xref py py-class",
"#text": "ValueError"
},
"operation",
"'__key__'",
"=="
],
"#text": "if is not one of the\nspecified values, or if a filter names but\npasses invalid operator ( is required) or value (a key\nis required)."
}
}
}
]
}
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.ancestor",
"@ids": "gcloud.datastore.query.Query.ancestor",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.ancestor",
"desc_name": "ancestor"
},
"desc_content": {
"paragraph": "The ancestor key for the query.",
"field_list": {
"field": {
"field_name": "Return type",
"field_body": {
"paragraph": "Key or None"
}
}
}
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.dataset_id",
"@ids": "gcloud.datastore.query.Query.dataset_id",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.dataset_id",
"desc_name": "dataset_id"
},
"desc_content": {
"paragraph": "Get the dataset ID for this Query.",
"field_list": {
"field": {
"field_name": "Return type",
"field_body": {
"paragraph": {
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/functions.html#str",
"#text": "str"
}
}
}
}
}
}
},
{
"@desctype": "method",
"@domain": "py",
"@noindex": "False",
"@objtype": "method",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.fetch",
"@ids": "gcloud.datastore.query.Query.fetch",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.fetch",
"desc_name": "fetch",
"desc_parameterlist": {
"desc_parameter": [
"limit=None",
"offset=0",
"start_cursor=None",
"end_cursor=None",
"client=None"
]
},
"comment": {
"@xml:space": "preserve"
}
},
"desc_content": {
"paragraph": [
"Execute the Query; return an iterator for the matching entities.",
"For example:"
],
"literal_block": {
"@xml:space": "preserve",
"#text": ">>> from gcloud import datastore\n>>> query = datastore.Query('Person')\n>>> query.add_filter('name', '=', 'Sally')\n>>> list(query.fetch())\n[<Entity object>, <Entity object>, ...]\n>>> list(query.fetch(1))\n[<Entity object>]"
},
"field_list": {
"field": [
{
"field_name": "Parameters",
"field_body": {
"bullet_list": {
"list_item": [
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "limit"
},
"emphasis": "integer or None",
"#text": "() -- An optional limit passed through to the iterator."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "offset"
},
"emphasis": "integer",
"#text": "() -- An optional offset passed through to the iterator."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "start_cursor"
},
"emphasis": "bytes",
"#text": "() -- An optional cursor passed through to the iterator."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "end_cursor"
},
"emphasis": "bytes",
"#text": "() -- An optional cursor passed through to the iterator."
}
},
{
"paragraph": {
"literal_strong": {
"@refspecific": "True",
"#text": "client"
},
"reference": {
"@internal": "True",
"@reftitle": "gcloud.datastore.client.Client",
"@refuri": "datastore-client#gcloud.datastore.client.Client",
"literal": {
"@classes": "xref py py-class",
"#text": "gcloud.datastore.client.Client"
}
},
"#text": "() -- client used to connect to datastore.\nIf not supplied, uses the query's value."
}
}
]
}
}
},
{
"field_name": "Return type",
"field_body": {
"paragraph": {
"reference": {
"@internal": "True",
"@refid": "gcloud.datastore.query.Iterator",
"@reftitle": "gcloud.datastore.query.Iterator",
"literal": {
"@classes": "xref py py-class",
"#text": "Iterator"
}
}
}
}
},
{
"field_name": "Raises",
"field_body": {
"paragraph": {
"literal": "connection",
"#text": "ValueError if is not passed and no implicit\ndefault has been set."
}
}
}
]
}
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.filters",
"@ids": "gcloud.datastore.query.Query.filters",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.filters",
"desc_name": "filters"
},
"desc_content": {
"paragraph": "Filters set on the query.",
"field_list": {
"field": {
"field_name": "Return type",
"field_body": {
"paragraph": "sequence of (property_name, operator, value) tuples."
}
}
}
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.group_by",
"@ids": "gcloud.datastore.query.Query.group_by",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.group_by",
"desc_name": "group_by"
},
"desc_content": {
"paragraph": "Names of fields used to group query results.",
"field_list": {
"field": {
"field_name": "Return type",
"field_body": {
"paragraph": "sequence of string"
}
}
}
}
},
{
"@desctype": "method",
"@domain": "py",
"@noindex": "False",
"@objtype": "method",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.keys_only",
"@ids": "gcloud.datastore.query.Query.keys_only",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.keys_only",
"desc_name": "keys_only",
"desc_parameterlist": null,
"comment": {
"@xml:space": "preserve"
}
},
"desc_content": {
"paragraph": "Set the projection to include only keys."
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.kind",
"@ids": "gcloud.datastore.query.Query.kind",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.kind",
"desc_name": "kind"
},
"desc_content": {
"paragraph": "Get the Kind of the Query.",
"field_list": {
"field": {
"field_name": "Return type",
"field_body": {
"paragraph": {
"reference": {
"@internal": "False",
"@reftitle": "(in Python v2.7)",
"@refuri": "https://docs.python.org/library/string.html#module-string",
"#text": "string"
}
}
}
}
}
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.namespace",
"@ids": "gcloud.datastore.query.Query.namespace",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.namespace",
"desc_name": "namespace"
},
"desc_content": {
"paragraph": "This query's namespace",
"field_list": {
"field": [
{
"field_name": "Return type",
"field_body": {
"paragraph": "string or None"
}
},
{
"field_name": "Returns",
"field_body": {
"paragraph": "the namespace assigned to this query"
}
}
]
}
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.order",
"@ids": "gcloud.datastore.query.Query.order",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.order",
"desc_name": "order"
},
"desc_content": {
"paragraph": "Names of fields used to sort query results.",
"field_list": {
"field": {
"field_name": "Return type",
"field_body": {
"paragraph": "sequence of string"
}
}
}
}
},
{
"@desctype": "attribute",
"@domain": "py",
"@noindex": "False",
"@objtype": "attribute",
"desc_signature": {
"@class": "Query",
"@first": "False",
"@fullname": "Query.projection",
"@ids": "gcloud.datastore.query.Query.projection",
"@module": "gcloud.datastore.query",
"@names": "gcloud.datastore.query.Query.projection",
"desc_name": "projection"
},
"desc_content": {
"paragraph": "Fields names returned by the query.",
"field_list": {
"field": [
{
"field_name": "Return type",
"field_body": {
"paragraph": "sequence of string"
}
},
{
"field_name": "Returns",
"field_body": {
"paragraph": "Names of fields in query results."
}
}
]
}
}
}
]
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment