gpt4 book ai didi

mongoDB - URL 作为文档 ID

转载 作者:可可西里 更新时间:2023-11-01 09:23:45 26 4
gpt4 key购买 nike

考虑到我想为一堆不同的 URL 创建 mongoDB 文档:使用实际 URL 作为文档 _id 值而不是默认值 _id 的优缺点是什么? strong>BSON ObjectId。提前致谢!

干杯,格雷格

最佳答案

此处主题概述:http://www.mongodb.org/display/DOCS/Object+IDs

它必须是独一无二的,您可能会将自己置于必须自己解决碰撞的境地。最好保留默认的 _id 并简单地查询您存储在文档中的字段,这正是上帝 (10gen) 的意图。

来自 http://www.mongodb.org/display/DOCS/BSON

The element name "_id" is reserved for use as a primary key id, but you can store anything that is unique in that field. The database expects that drivers will prevent users from creating documents that violate these constraints.

来自#mongodb

stupid _id values will probably make querying slow, but that's about it

还有来自#mongodb 的另一个用户

Tell him the collisions will result in garbage data

关于mongoDB - URL 作为文档 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6716045/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com