[DOCS-563] documentation for valueOf() and toString() Created: 28/Sep/12  Updated: 30/Oct/23  Resolved: 18/Oct/12

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Eric Milkie Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Related
related to DOCS-584 Release notes for 2.2 should mention ... Closed
related to SERVER-7055 ObjectId to String type conversion di... Closed
related to DOCS-586 Document "str" property of ObjectId()... Closed
related to SERVER-2684 special types in shell (e.g. Timestam... Closed
is related to SERVER-6986 ObjectId#toString and ObjectId#valueOf Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
DOCS-584 Release notes for 2.2 should mention ... Sub-task Closed Kay Kim  
Participants:
Days since reply: 11 years, 17 weeks, 5 days ago

 Description   

valueOf() needs documentation. Need examples of the difference between valueOf() and toString(), especially for ObjectId type. The behavior of toString() changed in 2.2. The old behavior was to convert the ObjectId into a bare string (thus losing its type information); the new behavior is to produce text that indicates that it is an ObjectId with a hex value.



 Comments   
Comment by auto [ 19/Oct/12 ]

Author:

{u'date': u'2012-10-18T22:07:53-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}

Message: DOCS-563 minor edits
Branch: master
https://github.com/mongodb/docs/commit/4f6c70aef8355a186eeb43664a2378202244e67a

Comment by auto [ 19/Oct/12 ]

Author:

{u'date': u'2012-10-18T21:27:03-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}

Message: DOCS-563 fix links
Branch: master
https://github.com/mongodb/docs/commit/c1ea7143f2e4b737d3dd8670975a672b984cc066

Comment by auto [ 19/Oct/12 ]

Author:

{u'date': u'2012-10-18T21:11:01-07:00', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-563 additional edits
Branch: master
https://github.com/mongodb/docs/commit/74facd3722532ab47f09d3de5908616ace145825

Comment by auto [ 18/Oct/12 ]

Author:

{u'date': u'2012-10-18T15:39:31-07:00', u'email': u'samk@10gen.com', u'name': u'Sam Kleinman'}

Message: DOCS-563 additional edits
Branch: master
https://github.com/mongodb/docs/commit/7864c2ba3c208f63955847517b11d4e07fe8ba18

Comment by auto [ 18/Oct/12 ]

Author:

{u'date': u'2012-10-18T15:22:24-07:00', u'email': u'samk@10gen.com', u'name': u'Sam Kleinman'}

Message: edits: DOCS-563 objectId file
Branch: master
https://github.com/mongodb/docs/commit/a38372442818cdd28cd1f572f6d3b01265bde8fc

Comment by auto [ 18/Oct/12 ]

Author:

{u'date': u'2012-10-18T08:51:49-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}

Message: DOCS-563 586 add ObjectId() getTimestamp method and blurb
Branch: master
https://github.com/mongodb/docs/commit/131715dd96262307d0461b3e7c8ac694bd4a1a3e

Comment by auto [ 18/Oct/12 ]

Author:

{u'date': u'2012-10-17T15:30:58-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}

Message: DOCS-563 and DOCS-586 minor cleanup of ObjectId
Branch: master
https://github.com/mongodb/docs/commit/77bdcc09d704f792267d558c9a6350a9a32be175

Comment by auto [ 18/Oct/12 ]

Author:

{u'date': u'2012-10-17T15:26:49-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}

Message: DOCS-563 and DOCS-586 edits to ObjectId doc
Branch: master
https://github.com/mongodb/docs/commit/be7abf071b82d9b18416cd60306edb08becc4896

Comment by auto [ 18/Oct/12 ]

Author:

{u'date': u'2012-10-17T14:42:51-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}

Message: DOCS-563,586 ObjectId() class methods and field doc
Branch: master
https://github.com/mongodb/docs/commit/a3917219374d57db8a9525b7388ac7c870b8b1d0

Comment by Eric Milkie [ 28/Sep/12 ]

I believe that any overrides of .toString() or .valueOf() are all found within mongo/shell/utils.js

Comment by Eric Milkie [ 28/Sep/12 ]

This external post has some of the philosophy behind the changes:
http://javascriptweblog.wordpress.com/2010/05/03/the-value-of-valueof/

Comment by Eric Milkie [ 28/Sep/12 ]

I linked in the original server ticket, which has a description of the "before" and "after" formats for toString() for a variety of special types.
For valueOf(), after SERVER-2684 we started overriding it for ObjectID type, but we left its default behavior alone for other types, from what I can tell.

Comment by Ed Costello [ 28/Sep/12 ]

We'll figure it out…is it solely ObjectID that these affect?
ie, doesn't redefine valueof/tostring for all JS objects, just specific mongodb ones?

Comment by Ed Costello [ 28/Sep/12 ]

We don't presently document either of these (in docs or the wiki)…are the method changes specific to ObjectID or across all uses of .valueOf and .toString under the SM & v8 engines?

Generated at Thu Feb 08 07:38:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.