为什么mongoDB使用objectID? [英] Why mongoDB uses objectID?

查看:94
本文介绍了为什么mongoDB使用objectID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{ "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }

objectId的用途到底是什么?这是一个很大的数字,是使用时间戳生成的.

what exactly is the purpose of objectId? It's a big number that is generated using a timestamp.

如果看到任何Nosql是键值,我将用键查询值.

If I see any nosql which is key-value, I query with key the value.

这里我们使用键和值作为数据,并使用find()函数.

Here we use key and value in the as the data and use find () function.

所以,我试图了解我们何时真正需要该objectid? 授予用户查看对象ID值的权限的原因是什么?

So, I am trying to understand when we really need the objectid? What are the reasons behind that giving access to the user to view the value of the object ID?

阅读文档后,一个基本问题是mongo DB作为哈希表类型的实现吗?

After reading the docs, one basic question is mongo DB as hash table type implementation?

推荐答案

准备好文档后.一个基本问题是mongo DB作为哈希表类型的实现吗?

After readying doc..one basic question is mongo DB as hash table type implementation?

MongoDB使用 BSON (JSON的二进制形式). JSON对象基本上只是一个哈希表"或一组键/值对.

MongoDB used BSON, a binary form of JSON. A JSON object is basically just a "hashtable" or a set of key / value pairs.

对象id的用途到底是什么?这是随着时间而产生的大数字.

what exactly is the use of object id? that is a big number that is generated with time.

在MongoDB中,您存储的每个文档都必须有一个_id.如果您未为_id设置值,则MongoDB将自动为您生成一个值.如果在插入对象时具有唯一键,则可以使用该键.有关ObjectId的详细信息,请参见此处.

In MongoDB, each document you store must have an _id. If you do not set a value for _id, then MongoDB will automatically generate one for you. If you have a unique key when you are inserting the object, you can use that instead. For details on the ObjectId see here.

如果看到任何Nosql是键值,我将用键查询值.

If I see any nosql which is key-value, I query with key the value.

MongoDB不仅是键值. MongoDB在单个集合上支持多个索引,您可以查询许多不同的字段,而不仅仅是键"或"id".

MongoDB is not just key-value. MongoDB supports multiple indexes on a single collection, you can query on many different fields, not just the "key" or "id".

这篇关于为什么mongoDB使用objectID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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