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

Return types of find operations to not include the _id field

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.2.0
    • Affects Version/s: None
    • Component/s: None
    • 2
    • Not Needed

      What problem are you facing?

      When using operations like find, findOne or next, the return type is often TSchema which is either the default empty Document type, or the type we set for the collection using collection<Type>(). This is misleading as the return document also includes the _id field, which should be reflected in the type.

      What driver and relevant dependency versions are you using?

      node.js driver 4.1.3

      npm v8.0.0

      Node.js v16.13.0

      Steps to reproduce?

      Define a collection using db.collection<YourCustomType>("name")

      Use a find method like findOne on the collection: collection.findOne({foo: "bar"})

      Observe how the return type is equal to YourCustomType and does not include _id

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            rodrigoleitao25@gmail.com Rodrigo Leitão
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: