Вопрос

I am using DynamoDB and zend framework.

I am able to fetch row from normal table using this.

$response['Items'] = $this->dbClient->query(
     array(
        "TableName" => "user",
        "KeyConditions" =>  array( 
                               "userId" => array(
                                             "ComparisonOperator" => ComparisonOperator::EQ,
                                             "AttributeValueList" => array(
                                                                       array(Type::NUMBER => 2))
                                                                     )
                                              )
                               )
           );

But How I can fetch information based on Global secondary indexes. I have two fields in this table Id and email.

I want to search based on email and getting Id from Global secondary index table. And I want to use this id to get user's all other information from main user table. I want to do this in local DynamoDB.

How I can fetch id based on email from Global secondary index table in zend framework?

Это было полезно?

Решение

You just have to add index name while query, but in your global index email should be hash here all the attribute will be projected.

   $response = $this->dbClient->query(
       array(
            "TableName" => "user",
            "IndexName" => "index name",
            "KeyConditions" => array(
                 "email" => array(
                      "ComparisonOperator" => ComparisonOperator::EQ,
                      "AttributeValueList" => array(
                          array(Type::STRING => "email@abc.com"))))));

then you can fetch userId

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top