0

我要爲我的角Js應用程序設置分頁。我目前正在使用這個查詢。 query documention分頁在發電機db

TableName: 'articles_staging', 
       IndexName: 'feeds_feedname-index', 
       KeyConditions: { 
        "feeds_feedname": { 
         "AttributeValueList": [{ 
           "S": arrayfeeds[j] 


          } 

         ], 

         "ComparisonOperator": "EQ" 
        } 
       } 

我怎麼應用這個分頁。

+0

您是否檢查過用於分頁的角度引導UI? – 2014-09-03 06:14:43

+0

actully我需要在amazon-web服務在dynamodb寫幫助。 – 2014-09-03 06:16:10

回答

0

那麼,新的壞的是,在DynamoDB中沒有分頁(特別是沒有OFFSET參數)。我有這個功能scan()處理分頁(PHP代碼):

private function scan($table, $filter = [], $select = null, $limit = 10) 
{ 
    $page = isset($_GET['page']) ? $_GET['page'] : 0; 
    $options = [ 
     'TableName' => $table, 
     'Count' => true, 
    ]; 

    if (!empty($limit)) { 
     $options['Limit'] = $limit; 
    } 

    if (!is_null($select)) { 
     $options['Select'] = $select; 
    } 

    if (!empty($filter)) { 
     $options['ScanFilter'] = $filter; 
    } 

    // For pagination: 
    $results = $this->_client->scan($options); 

    while ($page > 0 && isset($results['LastEvaluatedKey'])) { 
     $results = $this->_client->scan($options); 
     $options['ExclusiveStartKey'] = $results['LastEvaluatedKey']; 
     $page--; 
    } 

    return $results; 
} 

$this->_client指DynamoDB連接

正如你所看到的,我在響應檢查LastEvaluatedKey,如果它的存在,比它意味着數據庫仍然留下沒有返回的條目。比我循環直到這個參數消失。