newObjectId()ObjectId("5cd7f205348bc646")>newObjectId()ObjectId("5cd77458f )ObjectId(&"/> newObjectId()ObjectId("5cd7f205348bc646")>newObjectId()ObjectId("5cd77458f )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中文網其他相關文章!