2

I'm currently working on Azure Cosmos DB and I'm trying to update a property for all the items present in the container using SQL Query, but I'm getting an error which says "Syntax error, incorrect syntax near 'UPDATE'.". Can anyone help me with this, I want to know whether I'm doing it wrong or the Azure Cosmos SQL doesn't support "Update" function. The SQL query which I've used is:

UPDATE c
set ttl = 10

Thanks in advance!!!

1 Answer 1

3

No Cosmos SQL API does not have the support Update yet.

You need to use the SDK inorder to perform Bulk Upserts, if you are using .NET you could perform Bulk operations as mentioned here.

public async Task BulkUpsert(List<SomeItem> items)
{
    var concurrentTasks = new List<Task>();

    foreach (SomeItem item in items)
    {
        concurrentTasks.Add(container.UpsertItemAsync(item, new PartitionKey(item.PartitionKeyField)));
    }

    await Task.WhenAll(concurrentTasks);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.