Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4398

Investigate NODE-4397 - can't use string as ObjectId

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • 1
    • Not Needed

      NODE-4397 Description
      Just upgraded from 3.7 to 4.0.1 (and then 4.7.0, but the same issue remains).  I'm using TypeScript, and am using strings instead of ObjectIds for my _id fields. After the upgrade, I get the error:
        Type 'string' is not assignable to type 'ObjectId'
      when I try to do something like:
        await db.collection('mycollection').insertOne({_id: 'abcdefg', foo: 'bar'});

      are string IDs not supported anymore?  Or is this just an omission of the type definitions?

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: