I modify my original stored proc to show the issue. I somehow struggle to get the document(s) back from the collection. Now, I just try to get the document by id, and it still fails to do so. I always get the "True error" message back which means no document. However, when I run the query in the query window, the document is returned without any issue. I really have no idea what the issue can be. Below is my code. Any help appreciated.
function removeDisconnectedUserFromAllRooms(connectionID){
var collection = getContext().getCollection();
var collectionLink = collection.getSelfLink();
var response = getContext().getResponse();
var nodesBatch = [];
if (!connectionID) throw new Error("The id is undefined or null.");
var query = {query: "select * from rooms where rooms.RoomID = @connectionID", parameters: [{name: "@connectionID", value: connectionID}]};
var isAccepted = collection.queryDocuments(collectionLink, query, function (err, documents, options) {
if (err) throw err;
if (documents.length > 0) {
response.setBody(documents.length);
}
else if (options.continuation){
response.setBody("has token");
}
else {
// Else a document with the given id does not exist..
response.setBody("true error");
}
});
}
if(!isAccepted) {
throw new Error("The stored procedure timed out.");
}
}

