[SERVER-5439] Add ObjectId.toHexString() Created: 29/Mar/12  Updated: 08/Mar/13  Resolved: 07/Oct/12

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 2.0.4, 2.1.0, 2.2.0
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Tad Marshall
Resolution: Won't Fix Votes: 2
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to DOCS-584 Release notes for 2.2 should mention ... Closed
is related to DOCS-586 Document "str" property of ObjectId()... Closed
Participants:

 Description   

This method should return the hex string representation of the ObjectId.

var o = new ObjectId()
o.valueOf() //yields either ObjectId("4f74646d2a0368211d9a16bc") or "4f74646d2a0368211d9a16bc" depending on the version
o.toString() //the opposite representation from valueOf()
o.toHexString() // should get only the string - "4f74646d2a0368211d9a16bc"



 Comments   
Comment by Tad Marshall [ 07/Oct/12 ]

This proposed method would duplicate the functionality of the "str" property, but it comes too late to give us the backwards compatibility workaround that we have in "str". I filed DOCS-586 to document "str", making this function redundant.

Comment by Adam Kusmierz [ 07/Oct/12 ]

Dup of SERVER-6986 and related to DOCS-563 and SERVER-2684.

Comment by Adam Kusmierz [ 07/Oct/12 ]

MongoDB shell version: 2.0.7
connecting to: test
> var o = new ObjectId()
> o.valueOf();
ObjectId("5071631479c87d8e875c4695")
> o.toString();
5071631479c87d8e875c4695
>

MongoDB shell version: 2.2.0
connecting to: test
> var o = new ObjectId()
> o.valueOf();
50716306e3c7b3ad72e4a7a6
> o.toString();
ObjectId("50716306e3c7b3ad72e4a7a6")
>

Should I get Mongo version to convert ID to string? Any news from dev team?

Generated at Thu Feb 08 03:08:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.