newObjectId()ObjectId("5cd7bf316d78f205348bc647")>newObjectId()ObjectId(&"/> newObjectId()ObjectId("5cd7bf316d78f205348bc647")>newObjectId()ObjectId(&">
要生成ObjectID,请在MonogDB shell中使用以下语法 −
new ObjectId()
让我们实现上述语法来生成MongoDB中的ObjectID −
> new ObjectId() ObjectId("5cd7bf2f6d78f205348bc646") > new ObjectId() ObjectId("5cd7bf316d78f205348bc647") > new ObjectId() ObjectId("5cd7bf336d78f205348bc648") > new ObjectId() ObjectId("5cd7bf346d78f205348bc649") > new ObjectId() ObjectId("5cd7bf356d78f205348bc64a") > new ObjectId() ObjectId("5cd7bf396d78f205348bc64b") > new ObjectId() ObjectId("5cd7bf3a6d78f205348bc64c")
如上所示,每次都会得到一个新的ObjectId。
以上是如何在MongoDB中生成ObjectID?的详细内容。更多信息请关注PHP中文网其他相关文章!