Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identity Column in DocumentDB

Is it possible to have identity column in documentDB for autoincrement, it's usually handy for IDs? Any link or hint relating to it can be useful.

Thanks.

like image 336
Sandip Bantawa Avatar asked Nov 02 '14 16:11

Sandip Bantawa


1 Answers

AFAIK, DocumentDB does not have this kind of concept. Each document in DocumentDB has an id property which uniquely identifies the document but that id field is of type string. When creating a document, you may choose not to specify a value for this field and DocumentDB assigns an id automatically but this value is a GUID. Thus if you wish to achieve auto increment type functionality, you would need to handle this on your own. However please do keep in mind that it is a string type property so even if you're handling this on your own, you would need to pad your string with zeros so that values are returned in proper order i.e. 1, 2, 3 etc. instead of 1, 10, 11, ... 19, 2, 20 ....

like image 69
Gaurav Mantri Avatar answered Sep 23 '22 11:09

Gaurav Mantri