[GODRIVER-1978] Document that _id should be the first field in a Document Created: 22/Apr/21  Updated: 30/Mar/22

Status: Backlog
Project: Go Driver
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Benji Rewis (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Not Needed

 Description   

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.


Generated at Thu Feb 08 08:37:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.