-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.0.2
-
Component/s: Native
-
None
Currently, we mutate some user-owned objects like queries and options. The biggest offender is https://github.com/mongodb/node-mongodb-native/blob/3.0.0/lib/utils.js#L386, where we add a session to the passed-in options object.
This can lead to some problems and unintended side effects. For one, this will cause an error if the passed in object is frozen or sealed. Additionally, it can have unintended consequences if combined with Proxies and/or custom setters.
Ideally, we should not mutate user-owned objects, while feeling free to mutate objects that we own (collections, topologies, etc.). The only reason we should elect to mutate would be if there are major performance considerations.