在DocumentDB标识列 [英] Identity Column in DocumentDB

查看:121
本文介绍了在DocumentDB标识列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时有可能有标识列documentDB自动增量,它通常是得心应手IDS?有关它的任何链接或提示可能是有用的。

Is it possible to have identity column in documentDB for autoincrement, its usually handy for ids? any link or hint relating to it can be useful

感谢

推荐答案

据我所知,DocumentDB没有这种概念。在DocumentDB每个文档都有一个 ID 属性唯一标识文档但 ID 字段是字符串类型。当创建一个文档,你可以选择不指定此字段的值,并DocumentDB自动分配一个ID,但这个值是一个GUID。因此,如果你想实现自动增量类型的功能,您将需要处理这个你自己的。但是请你记住,这是一个字符串类型的属性,因此,即使你是在自己的处理,你将需要垫零的字符串,以便值在正确的顺序,即1,2,3等返回代替1-,10,11,... 19,2,20 ....

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 ....

这篇关于在DocumentDB标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆