Wrong assumption about ID property?


i'm trying upload following json document:

{ id: { key: "qwerty" } }

this fails following (client) error message json.net: "can not convert object string". similar error occurs document of form:

{ id: [ "a", "b", "c" ] }

documentdb assumes when there id property has string value doesn't have case.

the error result of attempt explicit cast of jobject (or jarray) string (in jtoken class: public static explicit operator string(jtoken)).


documentdb requires id of type string every document.

if supply id, must be string , must be unique. if not, error similar 1 receiving.

if not supply value id, documentdb generate unique id (as string) you.

if have complex type, jobject or jarray, want make unique document, let documentdb assign unique string id property not putting in id, and insert "unique key" in different property. use pre trigger ensure uniqueness of before persisting record in database.

create hash of object or array , assign hash value id property. work long hash unique.


Microsoft Azure  >  Azure Cosmos DB



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'