Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1978

Document that _id should be the first field in a Document

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Documentation
    • Labels:
      None
    • Not Needed

      For performance reasons, the server recommends that the _id field in any inserted Document be the first one. transformAndEnsureID() used to move the _id field of any document to be first, but as of GODRIVER-1180, it no longer does.

      We'd like to avoid changing the order of a Document that the user has created, but we should document that putting _id in any position but the first in an ordered Document insertion can potentially cause a loss in performance.

      Additionally, we should document that if users do not specify an _id in a bson.D, one will be added for them and added first. Finally, we should mention that there's no way to guarantee the position of a manually-added _id field in a bson.M.

            Assignee:
            Unassigned Unassigned
            Reporter:
            benji.rewis@mongodb.com Benji Rewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: