Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adds DynamoDB Adapter #333

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: delete and rename attribute to use scan
  • Loading branch information
ajwad-shaikh committed Oct 14, 2023
commit 4f6d6a2128f0bb17ce9ca0c8b6697d51feb08b32
10 changes: 6 additions & 4 deletions src/Database/Adapter/DynamoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,10 @@ public function deleteAttribute(string $collection, string $id): bool
$id = $this->filter($id);
$queryParams = [
'TableName' => "{$this->getNamespace()}_{$collection}",
'ProjectionExpression' => '_id'
'ProjectionExpression' => '#id',
'ExpressionAttributeNames' => [ '#id' => '_id' ],
];
$items = ($this->client->query($queryParams))['Items'];
$items = ($this->client->scan($queryParams))['Items'];
foreach ($items as $item) {
$updateParams = [
'TableName' => "{$this->getNamespace()}_{$collection}",
Expand Down Expand Up @@ -386,9 +387,10 @@ public function renameAttribute(string $collection, string $old, string $new): b
$new = $this->filter($new);
$queryParams = [
'TableName' => "{$this->getNamespace()}_{$collection}",
'ProjectionExpression' => "_id, {$old}",
'ProjectionExpression' => "#id, {$old}",
'ExpressionAttributeNames' => [ '#id' => '_id' ],
];
$items = ($this->client->query($queryParams))['Items'];
$items = ($this->client->scan($queryParams))['Items'];
foreach ($items as $item) {
$oldItemValues = $item[$old];
$oldItemValue = null;
Expand Down