-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Minor - P4
-
Affects Version/s: 1.5.0
-
Component/s: Bson
-
None
-
Needed
-
Problem Statement/Rationale
As per docs https://www.mongodb.com/docs/manual/reference/method/ObjectId/
ObjectId.str should be a hexadecimal string representation of the object but is undefined.
ObjectId.valueOf() should return ObjectId.str but returns self.
ObjectId.toString() should return a ObjectId("HEX") string but returns a HEX string.
Steps to Reproduce
F:\Workspace>mongosh
Current Mongosh Log ID: 62c9a46047cd15a19415dc03
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.0
Using MongoDB: 5.0.9
Using Mongosh: 1.5.0> oid = new ObjectId("62c9a4673f0e25372db170ae")
ObjectId("62c9a4673f0e25372db170ae")
> typeof oid
object
> oid.str> typeof oid.str
undefined> oid.toString()
62c9a4673f0e25372db170ae> typeof oid.toString()
string> oid.valueOf()
ObjectId("62c9a4673f0e25372db170ae")> typeof oid.valueOf()
object> oid === oid.valueOf()
true
- is duplicated by
-
MONGOSH-1414 ObjectId methods valueOf() and str return undefined
- Closed