[Python] Increment value in cosmoDB when multiple partition keys exist

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    inserting and updating/patching data basically works with python. Now I have a container in Cosmosdb with multiple partition keys.

    when using a select like that

    _uuid = "%some UUID%"
    SELECT * FROM c where c.month = "01/25" and c.two = "_uuid"


    I can find the item !

    now it has a nested structure and I like to increment a counter with

    operations = [{ "op": "incr", "path": "/usage/counter", "value": 1}]
    response = container.patch_item(item='', partition_key='01/26-_uuid', patch_operations=operations)


    even if I add the right item id it fails with

    Partition key provided either doesn't correspond to definition in the collection or doesn't match partition key field values specified in the document


    how would I correctly increment the counter with multiple partion keys ?

    Continue reading...

Compartilhe esta Página