Ayman
Ayman

Reputation: 1463

Prevent empty PartitionKey in CosmosDb

I wanted to prevent any document create/update in Cosmos db with empty or null PartitionKey. Is this possible from a db level?

Upvotes: 0

Views: 251

Answers (2)

Matt Douhan
Matt Douhan

Reputation: 733

If your collection is setup with a partition key, I don't see how you can update it using any SDK without specifying it because how would CosmosDB know in what partition to put it?

Of course if you create a null partition key that is a different story.

Upvotes: 0

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

AFAIK, it is not possible to enforce this constraint from the database level. You would need to implement this from the application side only.

Upvotes: 2

Related Questions