Mongo script gotchas
- no
console.log
, useprint
instead - no
Object.entries
,Object.values
useObject.keys
Map
,Set
are not spec-compliant,Set
values are stringified,Map
are not iterable, don't use themfor (const foo of [1]) {}
is also broken, it needs alet
/var
instead ofconst
(warning:let
might not be block-scoped as per spec, they probably just replace it byvar
)- Use
doc._id + ''
to get the objectId as hex string, don't rely on template strings also, they seem to incorrectly invokedoc._id.toString()
which returns 'ObjectId(hexstring)' - Outdated RegExp, not supporting look-behinds