Azure / azure-cosmosdb-js-server

The JavaScript SDK for server-side programming in Azure Cosmos DB
MIT License
178 stars 153 forks source link

When will these these stored procedures be updated to support partitioned collections? #4

Closed stackoverflower closed 6 years ago

stackoverflower commented 8 years ago

Do you plan to update these stored procedures to support partitioned collections anytime soon?

arramac commented 8 years ago

@stackoverflower stored procedures are already supported for partitioned collections. There are no changes in the programming API.

However the execution semantics are different. Stored procedures for partitioned collections must include a partition key and are scoped to the transaction boundary of a single partition key value.

steve-torchia commented 6 years ago

@arramac can you show an example of how to include the partition key in the bulkDelete.js Stored Procedure sample?

When I try to save the bulkDelete.js SP in a partitioned collection I get the following error message:

Database Account: sktcosmosdb, Script: sktMultPart, Message: {"code":400,"body":"{\"code\":\"BadRequest\",\"message\":\"Replaces and upserts for scripts in collections with multiple partitions are not supported.\r\nActivityId: 685d2aaa-c509-4b76-ba1b-6181f4b40449, Microsoft.Azure.Documents.Common/1.17.101.1\"}","activityId":"685d2aaa-c509-4b76-ba1b-6181f4b40449"}

That same SP saves/runs fine in a single partition collection - so I'm missing something

diaconesq commented 6 years ago

@steve-torchia It's not an upsert inside the SP that's failing. It's upserting the SP itself: https://stackoverflow.com/questions/42299815/saving-testing-stored-procedures-triggers-maybe-user-defined-functions-for-p

arramac commented 6 years ago

+1 to @steve-torchia. BTW, the issue of upserting the SP itself has also been fixed. Closing this issue.

diaconesq commented 6 years ago

I just hit the 'upsert SP on partitioned collection' issue today. I would expect the fix to be server-side, right?

eladkamin commented 5 years ago

I just got the 'Upserts for scripts in collections with multiple partitions are not supported' error today. When will upsert stored procedures will be updated to support partitioned collections?

chlahav commented 5 years ago

@eladkamin I had the same issue, using the ReplaceStoredProcedureAsync function as described in the stackoverflow thread from above worked perfectly for me

try 
{
    await _client.CreateStoredProcedureAsync(...);
} 
catch(DocumentClientException dex) when (dex.StatusCode == HttpStatusCode.Conflict) 
{ 
    await _client.ReplaceStoredProcedureAsync(...);  
}