Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1502

valueOf() method does not work on ObjectId

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • No version
    • Affects Version/s: 1.10.1
    • Component/s: Shell API
    • None
    • Environment:
      OS: Windows
      mongosh version: 1.10.1

    • Not Needed

      On ObjectId method valueOf() does not return any value, thus getTimestamp() is also not working:

       

       

      mongosh --nodb
      Current Mongosh Log ID: 64a27280cb0a6095e554ee18
      Using Mongosh:          1.10.1
      
      (NoDB)> ObjectId("64a24a7f51e511bca00dc711")
      ObjectId("64a24a7f51e511bca00dc711")
      (NoDB)> ObjectId("64a24a7f51e511bca00dc711").valueOf()
      
      (NoDB)> ObjectId("64a24a7f51e511bca00dc711").getTimestamp()
      Uncaught:
      TypeError: Cannot read properties of undefined (reading 'slice')
          at c:\Programs\MongoDB\mongotypes.js:44:2719
          at ObjectId._arv.getTimestamp (c:\Programs\MongoDB\mongotypes.js:44:2954)
          at REPL4:25:240
          at REPL4:39:5
          at REPL4:43:3
          at Script.runInContext (node:vm:141:12)
          at PrettyREPLServer.defaultEval (node:repl:574:29)
          at bound (node:domain:433:15)
          at PrettyREPLServer.runBound (node:domain:444:12)
          at C:\data\mci\f8d9149a5a29353661afdc2304e7e56e\tmp\boxednode\mongosh\node-v16.20.1\Release\node.exe:22:91768
      (NoDB)>
       

       

       

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            wernfried.domscheit@sunrise.net Wernfried Domscheit
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: