• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to delete properties from an item in CosmosDB

Resolved: How to delete properties from an item in CosmosDB

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a Python code to manage a collection in Cosmos DB by utilizing CosmosClient. It provides upsert_item, query_item, create_item, etc. But I need to delete properties from an existing item. Because the item could contain lots of properties, I wonder if there any better approach other than updating the whole item. I tried following code:
This only updated p1 and p2 to empty string instead of deleting them. Anyone knows how to delete them programmatically? Since the partitionKey is POLICY, I couldn’t delete them in the portal.

Answer:

To delete an item from a dictionary in Python, you will need to use del. So your code would be something like:

If you have better answer, please add a comment about this, thank you!

azure-cosmosdb
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Unable to run Docker .NET 6 console image

02/04/2023

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.