Mongo script gotchas
- no
console.log, useprintinstead - no
Object.entries,Object.valuesuseObject.keys Map,Setare not spec-compliant,Setvalues are stringified,Mapare not iterable, don't use themfor (const foo of [1]) {}is also broken, it needs alet/varinstead ofconst(warning:letmight 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