HENNGE / aiodynamo

Asynchronous, fast, pythonic DynamoDB Client
https://aiodynamo.readthedocs.io/
Other
73 stars 21 forks source link

How to update map element using a pattern? #108

Closed dimaqq closed 2 years ago

dimaqq commented 2 years ago

Described in https://dev.to/matthewvielkind/updating-values-in-dyanmodb-map-attributes-can

UpdateExpression="SET players.#player_id.score = :score_val",  
ExpressionAttributeNames={"#player_id": player_id},  

I'm not sure what the API is in this case... Would I need to overload F?

ojii commented 2 years ago

F("players", player_id, "score").set(score_val)

dimaqq commented 2 years ago

🤔 what if player_id evaluates to string, in case of nested mapping?

ojii commented 2 years ago

aiodynamo escapes all names, so that would translate to SET #n1.#n2.#n3 = :v1 with EAN {"#n1": "players", "#n2": player_id, "#n3": "score"}

dimaqq commented 2 years ago

Perfect! Would be awesome to have a "recipes" section, but this is enough for me.