我正在开发一个大数据规模的系统。目前,我正在使用少于300k的文档测试存储过程。
我关注这个例子: DocumentDB server-side programming: Stored procedures, database triggers, and UDFs
“createDocument”和“replaceDocument”到目前为止工作正常。 但是无论我尝试了多少种方式,queryDocuments根本不起作用。我试图在很多地方抛出异常但是在callBack中抛出异常并没有被击中。
是否有人在存储过程中成功使用了queryDocuments()?
function MoveTree(nodeJson, targetParentNodeJson) {
var node = JSON.parse(nodeJson);
var targetParentNode = JSON.parse(targetParentNodeJson);
var collection = getContext().getCollection();
var collectionLink = collection.getSelfLink();
var count = 0;
//<==Tried put throw exception here and it is hit
var node;
var IsAccept = collection.queryDocuments(
collection.getSelfLink(),
'SELECT * FROM Nodes p where p.id = "' + nodeId + '"',
function (err, documents, responseOptions) {
//<==Tried put throw exception here but it is not hit
if (err) throw new Error(err);
if (!documents || documents.length != 1) throw new Error("Unable to find node.");
node = documents[0];
//<==Tried put throw exception here but it is not hit
});
//<==Tried put throw exception here and it is hit
// ... }
答案 0 :(得分:0)
正如Larry所提到的,问题是您没有设置nodeId
变量...运行时会出现以下错误消息:
Encountered exception while executing Javascript. Exception = ReferenceError: 'nodeId' is undefined