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 时,它会在 _id 字段中创建具有当前时间戳的唯一值,但我想将具有自己时间戳的唯一值插入到 _id 字段中。我可以这样做吗?
默认情况下,MongoDB 驱动程序(官方支持的驱动程序,无论如何)将该_id字段设置为ObjectId,一种特殊的数据类型。如果您想覆盖它,您可以将该_id字段设置为具有您想要的任何值的任何数据类型。
_id
ObjectId
参考