I've been observing some strange behaviour in a stored procedure in Azure Cosmos DB using javascript API (https://docs.microsoft.com/en-us/azure/cosmos-db/programming#javascript-language-integrated-query-api)
Assuming there is a document in the database with the body.id = '---' the procedure below correctly return that document. However, if I comment the line 'return found ' and uncomment the lines with 'if (1==1)' then the stored procedure returns an empty result. I tried changing it to if (found){return found;} else{return false;}' - same empty output. Also, same happens if I write 'found = found && (1==1);' after 'let found = c.body.id != null && c.body.id ==t;'
Is this a Javascript bug or me doing something wrong?
// SAMPLE STORED PROCEDURE
function sample() {
__.filter(c=>{
//return true;
let t = "---";
let found = c.body.id != null && c.body.id ==t;
return found; <---
//if (1==1){
// return found;
//}
}
, {pageSize: -1},
(a, b, c)=>{
__.response.setBody(b);
return;
});
}