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

Filter on keys in map attribute type #43

Open
bjugan opened this issue Feb 1, 2024 · 0 comments
Open

Filter on keys in map attribute type #43

bjugan opened this issue Feb 1, 2024 · 0 comments

Comments

@bjugan
Copy link

bjugan commented Feb 1, 2024

Hi,

First, thanks for creating this great package :-)

Is there any way to filter on keys in the map attribute type?

Example:
->filter('person.name', 'John')

I'm still new to DynamoDb and I'm sorry if I'm missing something obvious.

Actually, I did a temporary hack to solve it. Seems to work for my use case, but not very well tested.

// Builder.php

public function where($column, $operator = null, $value = null, $boolean = 'and')
{
    // Convert column and value to ExpressionAttributes.
    if (! $column instanceof Closure) {
        // The column has nested keys
        if (Str::contains($column, '.')) {
            $column = Str::of($column)
                ->explode('.')
                ->map(fn ($attribute) => $this->expression_attributes->addName($attribute))
                ->implode('.');
        } else {
            $column = $this->expression_attributes->addName($column);
        }

        if ($value !== null) {
            $value = $this->expression_attributes->addValue($value);
        }
    }
   ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant