翻译或纠错本页面
- Reference >
- mongo Shell Methods >
- Object Constructors and Methods >
- ObjectId.valueOf()
ObjectId.valueOf()¶
- ObjectId.valueOf()¶
返回: The value of the ObjectId() object as a lowercase hexadecimal string. This value is the str attribute of the ObjectId() object. 在 2.2 版更改: In previous versions ObjectId.valueOf() returns the ObjectId() object.
In the following example, call the valueOf() method on an ObjectId (e.g. ObjectId("507c7f79bcf86cd7994f6c0e")):
ObjectId("507c7f79bcf86cd7994f6c0e").valueOf()
This will return the following string:
507c7f79bcf86cd7994f6c0e
You can confirm the type of this object using the following operation:
typeof ObjectId("507c7f79bcf86cd7994f6c0e").valueOf()