How can we improve Azure Cosmos DB?

Support multiple collections in stored procedures

Currently CosmosDB Stored procedures only allow access to a SINGLE collection (because they seem to be scoped to collections rather than to the database), via getContext() :

var collection = getContext().getCollection();

But any "useful" / "real-life" application using ComosDB will typically have to interact with more than one collection. For example, it is currently IMPOSSIBLE to insert documents into two distinct collections within a database using a single stored procedure -- a VERY SERIOUS drawback / limitation.

I would propose that stored procedures be scoped to the database level and then we would be allowed to do something like:

var widgets_collection = getContext().getCollection( "widgets" );
var gadgets_collection = getContext().getCollection( "gadgets" );

A single stored procedure would have access to any collection within the database. Also, operations on documents within multiple collections would be a single atomic transaction.

78 votes
Sign in
Sign in with: oidc
Signed in as (Sign out)
You have left! (?) (thinking…)
bdcoder shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: oidc
Signed in as (Sign out)
  • Tarik commented  ·   ·  Flag as inappropriate

    I just noticed this limitation, and it SUCKS. As mentioned in the description, how can anyone take CosmosDB seriously if we can't even update multiple collections in a single transaction? And this is NOT on your roadmap. Very disappointed indeed.

  • Amina commented  ·   ·  Flag as inappropriate

    I am using cosmo db for my application. How can I query data from multiple collections, perform operations on it and then save it in another collection. If stored procedures are at collection level, what is the work around to do this type of stuff. Should I switch to other NoSql databases like MongoDB or Cassandra

Feedback and Knowledge Base