In the legacy shell, MinKey and MinKey() are treated the same when sent over the wire. This is convenient for users, but not something we can easily emulate in mongosh, where MinKey is treated like any other function, and serialized as a function when sent over. This can be an issue e.g. when used as a sharding split key.
I don’t think we can address this in mongosh itself. Our options would be:
- Doing nothing and documenting the current state
- Asking the Node.js driver to check for typeof value === 'function' after checking the BSON type against MaxKey/MinKey instead of before, then modifying our MinKey/MaxKey shell builtins to have ._bsontype properties
- Asking the Node.js driver to emulate the legacy shell’s behaviour, i.e. treat the MinKey class like the MinKey() value itself when serialized as BSON
- depends on
-
NODE-3693 Make it possible to add a _bsontype to function objects
- Closed
- is related to
-
MONGOSH-1782 MinKey/MaxKey serialization behaves differently in browser REPL
- Open