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.
我有一个没有 _id 索引的上限集合,我根本不需要 _id,但是 PHP mongo 驱动程序总是在插入时添加一个 _id。
可以使用 mongo shell 抑制 _id 的自动生成
如何使用 PHP 抑制插入时的 _id?
你不能摆脱 _id ,但你可以覆盖它。因此,您可以将 1 列数据插入 _id 字段。
例如。
$myCollection->insert(array("_id" => 2000, "data" => "someData));