The documentation states equivalence for the code snippets below. But in the first case I can do operations on the documents collection inside the callback function, while the map function in the latter only works on one document. I do want to group values of the document, which I could do in the callback but not in the map function. Is there a way to accomplish this with the "JavaScript Language Integrated Query"? And how would I set the response body properly?
__.queryDocuments(__.getSelfLink(),
"SELECT docs.id, docs.message AS msg " +
"FROM docs " +
"WHERE docs.id='X998_Y998'"
,
function(err, docs, options) {
__.response.setBody(docs);
});
and
__.chain()
.filter(function(doc) {
return doc.id === "X998_Y998";
})
.map(function(doc) {
return {
id: doc.id,
msg: doc.message
};
})
.value();
For those with a similar problem: see the comment above. Put the callback logic in the value function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With