baopham / laravel-dynamodb

Eloquent syntax for DynamoDB
https://packagist.org/packages/baopham/dynamodb
MIT License
484 stars 128 forks source link

problem in nested query #280

Open BehroozBvk opened 3 months ago

BehroozBvk commented 3 months ago

Hi guys, does anyone know why the nested query does not work?

my item in dynamodb:

[{

    "id": "6606744528803",
    "role": {
      "name": "user",
    }
    "created_at": "2024-03-29T07:56:53+00:00",
    "updated_at": "2024-03-29T07:56:53+00:00",
  }]

My Model : User.php

<?php

namespace App\Models;

use BaoPham\DynamoDb\DynamoDbModel as Model;

class User extends Model
{
    protected $guarded = [];
}

Use case:

User::query() ->where('role.name', 'user')->get();

Even so, I tried not work:

User::query() ->where('user_role.name', 'user')->get();

Error:

Aws \ DynamoDb\ Exception\ DynamoDbException

Error executing "Scan" on "http://dynamodb-local:8000"; AWS HTTP error: Client error: POST http://dynamodb-local:8000 resulted in a 400 Bad Request response: {"type":"com.amazon.coral.validate#ValidationException","Message":"Invalid FilterExpression: Attribute name is a reser (truncated...) ValidationException (client): Invalid FilterExpression: Attribute name is a reserved keyword; reserved keyword: role - {"type":"com.amazon.coral.validate#ValidationException","Message":"Invalid FilterExpression: Attribute name is a reserved keyword; reserved keyword: role"}

thebatclaudio commented 3 months ago

You are using a reserved keyword (role): https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

Maybe you can try to implement this