How to set collection schema for CosmosDB MongoDB API 3.6 using Pymongo

Dakarai McCoy 96 Reputation points
2021-04-30T21:57:21.563+00:00

I have been searching for a way to instantiate a collection with a schema using the Pymongo API to access the Cosmos DB API.
I see the MongoDB API 3.6 does not support the 'myColl' database operator. Is there another method to do this? I need a method that I can script so that the process can be automated and run in the background.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,901 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Navtej Singh Saini 4,226 Reputation points Microsoft Employee Moderator
    2021-05-06T17:09:00.91+00:00

    @Dakarai McCoy

    We got info from our team - Cosmos DB doesn’t support schema validation, but here’s a workaround in the last answer of this thread.

    Hope this helps.

    Regards
    Navtej S


Your answer

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