On this page本页内容
ObjectId
(<hexadecimal>)¶Returns a new ObjectId value. 返回新的ObjectId值。The 12-byte ObjectId value consists of:12字节的ObjectId值包括:
While the BSON format itself is little-endian, the timestamp and counter values are big-endian, with the most significant bytes appearing first in the byte sequence.虽然BSON格式本身是小端的,但时间戳和计数器值是大端的,最重要的字节出现在字节序列的第一位。
ObjectId()
can accept the following parameter:可以接受以下参数:
hexadecimal |
ObjectId()
has the following attribute and methods:具有以下属性和方法:
str |
|
ObjectId.getTimestamp() |
|
ObjectId.toString() |
ObjectId(...) ”."ObjectId(...)" 的形式返回JavaScript表示。 |
ObjectId.valueOf() |
str attribute.str 属性。 |
To generate a new ObjectId, use 要生成新的ObjectId,请使用不带参数的ObjectId()
with no argument:ObjectId()
:
In this example, the value of 在本例中,x
would be:x
的值为:
To generate a new ObjectId using 要使用具有唯一十六进制字符串的ObjectId()
with a unique hexadecimal string:ObjectId()
生成新的ObjectId,请执行以下操作:
In this example, the value of 在本例中,y
would be:y
的值为:
Access the 访问str
attribute of an ObjectId()
object, as follows:ObjectId()
对象的str
属性,如下所示:
This operation will return the following hexadecimal string:此操作将返回以下十六进制字符串:
See also参阅