Closed tfe2012 closed 7 years ago
Or how Paginate result?
Most, if not all, AWS services use a next-key variable to implement pagination. i.e., you pass a next-key by reference to query functions, with the initial value set to null, and loop whenever this key is set to something other than null by the query functions.
e.g.:
$result = [];
do {
$page = $im->getRepository(User::class)->query(
"#hashKey = :hk AND #sortKey > :min",
[
":hk" => "abc",
":min" => 10,
],
'',
$lastKey
);
$result = array_merge($result, $page);
} while ($lastKey);
Maybe you can add this information to ODM tutorial ?
How about pagination?
If you want create data table.
fixed page-size pagination is not directly supported by DynamoDB, nor can it be supported by ODM. (partly bcz DynamoDB's evaluationLimit parameter is not same as returned page size)
check how facebook, twitter and many modern websites handle pagination in their main news feed page. There is no traditional "pagination", but constantly fetching something more, based on a last-fetched-record. This is quite similar to what DynamoDB supports.
So, if you would like to have old-school pagination, try the following methods:
Send query without 'indexName'
"#hashKey = :hk AND #sortKey > :min", [ ":hk" => "abc", ":min" => 10, ], '', $lastKey
It's impossible , you get
InvalidArgumentException
I'm sorry, it should be an idx name for GSI, or DynamoDbIndex::PrimaryIndex as default
What about boolean type?
This is my query. But you can't create boolean index in dynamodb console ->query( "#done = :done", [ ":done" => false, ], 'done-index', $lastKey );
you are right, you can't create boolean types in dynamodb index. and as a result, you can't query for boolean values. However, you can still use scan() with boolean type for non-indexed search.
Can you give me code example ?
The readme.md already shows simple use of scan() method.
Furthermore, I am not sure how familiar you know about DynamoDB. I suggest you fully read AWS' DynamoDB's dev-guide first, because that explains a lot more what DynamoDB is and what DynamoDB can do. ODM doesn't offer more than DynamoDB's ability, and many concepts are strongly based on DynamoDB's convention. (Like the difference between query/scan)
Thx, I find
Can you add to description, how to change query limits