문제

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