Cannot delete item from CosmosDB

前端 未结 1 1542
挽巷
挽巷 2021-01-21 16:16

I am trying to use an Azure Functions httpTrigger call to delete an item from my database.

import { CosmosClient,  } from \'@azure/cosmos\'

const httpTrigger: A         


        
相关标签:
1条回答
  • 2021-01-21 16:26

    When retrieving a document via container.item(), the two parameters are:

    • document id
    • partition key

    The 2nd parameter (partition key) needs to be the value of the partition key. In your example, you had the path to the partition key instead, so it's checking for a partition key value of "/id":

    const item = container.item('28a31558-ff8c-40c3-a7e8-1e8904c5ff72', '/id')
    

    This needs to be changed to:

    const item = container.item('28a31558-ff8c-40c3-a7e8-1e8904c5ff72', '<partition-key-value')
    
    0 讨论(0)
提交回复
热议问题