thank you for sharing your workarounds for some of the legacy functions that are not available in mongosh.
It’s worth mentioning that some of this functionality is available in a shell snippet that can be installed from within mongosh with
> snippet install mongocompat
I am curious: are you looking at having these functions defined in mongosh because they are used in a number of scripts that are part of your day-to-day work or because of muscle memory when you work with the shell interactively?