Ejemplo n.º 1
0
    def _to_client_query(self, client):
        """
    Returns a ``google.cloud.datastore.query.Query`` instance that represents
    this query.

    Args:
      client: (``google.cloud.datastore.client.Client``) Datastore client
        instance to use.
    """
        ancestor_client_key = None
        if self.ancestor is not None:
            ancestor_client_key = self.ancestor.to_client_key()

        # Resolve ValueProvider arguments.
        self.filters = self._set_runtime_filters()
        if isinstance(self.namespace, ValueProvider):
            self.namespace = self.namespace.get()

        return query.Query(client,
                           kind=self.kind,
                           project=self.project,
                           namespace=self.namespace,
                           ancestor=ancestor_client_key,
                           filters=self.filters,
                           projection=self.projection,
                           order=self.order,
                           distinct_on=self.distinct_on)
Ejemplo n.º 2
0
 def process(
         self,
         start_end,
         *unused_args,  # pylint: disable=invalid-name
         **unused_kwargs):
     start, end = start_end
     client = ds_client.Client(project=self._query_params['project'])
     query = ds_query.Query(client=client, **self._query_params)
     query.add_filter(self._timestamp_property, '>=', start)
     query.add_filter(self._timestamp_property, '<', end)
     for entity in query.fetch(client=client, eventual=True):
         yield entity
Ejemplo n.º 3
0
    def _to_client_query(self, client):
        """
    Returns a ``google.cloud.datastore.query.Query`` instance that represents
    this query.

    Args:
      client: (``google.cloud.datastore.client.Client``) Datastore client
        instance to use.
    """
        ancestor_client_key = None
        if self.ancestor is not None:
            ancestor_client_key = self.ancestor.to_client_key()
        return query.Query(client,
                           kind=self.kind,
                           project=self.project,
                           namespace=self.namespace,
                           ancestor=ancestor_client_key,
                           filters=self.filters,
                           projection=self.projection,
                           order=self.order,
                           distinct_on=self.distinct_on)