想知道:MongoDB _id默认情况下是唯一的吗? [英] Wonder: Is MongoDB _id unique by default?

查看:606
本文介绍了想知道:MongoDB _id默认情况下是唯一的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚坐在这里,又累又累,开始思考,

Just sitting here, late and tired and started thinking about,

默认情况下,MongoDB _id是唯一的还是我必须将其设置为唯一?

Is MongoDB _id unique by default, or do I has to set it to unique?

对于你们中的许多人来说,这只是一个愚蠢的问题.但是真的找不到任何东西.而且由于我的英语不好,当我得到一些冗长的解释时,有时会很难理解.

For many of you, just a stupid question. But can't really find anything about this. And with my bad english, it sometimes get hard to understand when I get some LONG explanation.

请和我一起忍受:-)

推荐答案

所有文档都包含一个_id字段.所有集合(有上限的集合除外)都会自动在_id上创建唯一索引.

All documents contain an _id field. All collections (except for capped ones) automatically create unique index on _id.

尝试一下:

db.system.indexes.find()

这篇关于想知道:MongoDB _id默认情况下是唯一的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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