Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 MongoDB 的新手,并为用户详细信息集合设计模式。是否建议在用户详细信息集合中使用 USER_NAME 作为 object_id?它的优点和缺点是什么?
唯一的数据库限制是 _id 必须是唯一的。你可以使用任何你喜欢的东西。
唯一需要考虑的就是对用户的引用。如果您有很多很多行,您最终可能会持有对用户文档的引用。使用 objectid 而不是用户名可能是有益的。objectid 是 12 个字节。
山姆