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

问题描述

documentDB 中是否可以有标识列用于自动增量,它通常对 ID 很方便?任何与之相关的链接或提示都可能有用.

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.

谢谢.

推荐答案

AFAIK,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 中的标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 18:37