DocumentDB: How to define a callback function in stored procedures when using JavaScript Language Integrated Query?
The documentation states the equivalence of the below code snippets. But in the former case, I can perform operations on the collection of documents inside the callback function, while the display function in the latter only works on one document. I want to group document values, which I could do in a callback, but not in a map function. Is there a way to do this with "JavaScript Language Integrated Query"? And how would I configure the response body correctly?
__.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();
+3
source to share