Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique keys #197

Closed
tlanda opened this Issue Oct 22, 2018 · 7 comments

Comments

Projects
None yet
2 participants
@tlanda
Copy link

tlanda commented Oct 22, 2018

Would you consider to support creating Collections with with a unique key policy?
https://docs.microsoft.com/en-us/azure/cosmos-db/unique-keys

@PlagueHO

This comment has been minimized.

Copy link
Owner

PlagueHO commented Oct 23, 2018

On initial investigation it appears the REST API documentation for collections (https://docs.microsoft.com/en-us/rest/api/cosmos-db/collections) has not been updated yet with information on how to set Unique Keys.

I could probably do some reverse engineering on the Azure Cosmos DB .NET Core SDK, but it hasn't been open sourced yet (https://github.com/Azure/azure-cosmosdb-dotnet/tree/master/sdk). Definitely possible to do, but will require more digging.

@PlagueHO

This comment has been minimized.

Copy link
Owner

PlagueHO commented Oct 26, 2018

Update: I've reached out to the MVP community and Cosmos DB team to see if there is any documentation available on this. Hopefully they'll just be able to quickly update the documentation.

@PlagueHO

This comment has been minimized.

Copy link
Owner

PlagueHO commented Oct 27, 2018

Update: I got some great info from the Cosmos DB team and MVPs. To create a unique policy we must add the following into the collection body:

"uniqueKeyPolicy": {
    "uniqueKeys": [
      { "paths": [ "/name", "/address "] },
      { "paths": [ "/email" ] }
    ]
  }

And:

coll = {"id": "collection_unique_keys", 'uniqueKeyPolicy': {'uniqueKeys': [{'paths': ['/field1/field2', '/field3']}]}}

@PlagueHO PlagueHO added in progress and removed question labels Oct 29, 2018

@PlagueHO

This comment has been minimized.

Copy link
Owner

PlagueHO commented Oct 29, 2018

@tlanda - I've finished work on this and am just finishing up the integration tests on this now. I'll have this out in the next release later on this week.

@tlanda

This comment has been minimized.

Copy link
Author

tlanda commented Oct 29, 2018

Great, thank you very much!

@PlagueHO PlagueHO closed this in c04a3d5 Oct 29, 2018

@PlagueHO

This comment has been minimized.

Copy link
Owner

PlagueHO commented Oct 29, 2018

A pleasure! Just releasing this to the PSGallery now as 2.1.12. Check there tomorrow.

@PlagueHO

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.