Why does this not compile?
function (newDoc, oldDoc, userCtx) {
if (newDoc !== null) {
if (newDoc.type.toLowerCase() === 'test') {
let thisDoesNotWork = 5;
}
}
}
It throws:
{
"error": "compilation_error",
"reason": "Expression does not eval to a function. (function (newDoc, oldDoc, userCtx) { if (newDoc !== null) { if (newDoc.type.toLowerCase() === 'test') { let thisDoesNotWork = 5; } } })"
}
Trying to extend it to newDoc by adding a new key to it does like the follwing does not work either and throws the same error but then only when you try to use it and not if you only declare it.
function (newDoc, oldDoc, userCtx) {
if (newDoc !== null) {
if (newDoc.type.toLowerCase() === 'test') {
let newDoc.thisDoesNotWork = 5;
}
}
}