Share via

Azure CosmosDB SQL API node js SDK - What is the easiest way to programmatically update all items in a container ?

Hament Pandya 6 Reputation points
2022-01-08T22:52:22.93+00:00

Hi,

I'm using Azure functions with apim.

I wish to add another key : value entry to every item in a specific container which contains around 400 entries.

e.g.

current item:

{
"a" : 1234,
"b": 3456
}

I wish tp update ALL items as follows:-

{
"a" : 1234,
"b": 3456
"newEntry": false
}

What is the easiest way to achieve this ?

Would you be able to provide an example of the code in node js (if possible) ?

Many thanks.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

Azure Cosmos DB
Azure Cosmos DB

An Azure NoSQL database service for app development.


1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,661 Reputation points Microsoft Employee Moderator
    2022-01-10T08:16:01.137+00:00

    @Hament Pandya Since this sounds as a one-off job, you could just write a simple update script that queries all documents and updates them one by one. I don't have a complete sample to share but I believe the links should help to start.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.