Azure cosmosdb DocumentDb存储过程集合。查询文档不工作
我正在开发一个大数据规模的系统。目前,我正在用不到300k的文档测试集合中的存储过程 我举这个例子: “createDocument”和“replaceDocument”目前运行良好。 但无论我用了多少种方法,queryDocuments根本不起作用。我试着在很多地方放置抛出异常,但回调中的抛出异常并没有受到任何影响 有人成功地在存储过程中使用了queryDocuments()吗Azure cosmosdb DocumentDb存储过程集合。查询文档不工作,azure-cosmosdb,Azure Cosmosdb,我正在开发一个大数据规模的系统。目前,我正在用不到300k的文档测试集合中的存储过程 我举这个例子: “createDocument”和“replaceDocument”目前运行良好。 但无论我用了多少种方法,queryDocuments根本不起作用。我试着在很多地方放置抛出异常,但回调中的抛出异常并没有受到任何影响 有人成功地在存储过程中使用了queryDocuments()吗 function MoveTree(nodeJson, targetParentNodeJson) { var n
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
函数MoveTree(nodeJson,targetParentNodeJson){
var node=JSON.parse(nodeJson);
var targetParentNode=JSON.parse(targetParentNodeJson);
var collection=getContext().getCollection();
var collectionLink=collection.getSelfLink();
var计数=0;
// 正如Larry提到的,问题是您没有设置nodeId
变量…这会在运行时导致以下错误消息:
在执行Javascript时遇到异常。exception=ReferenceError:'nodeId'未定义
变量nodeId
从未设置。您的意思是将其作为targetParentNode.\u id?另外,您在同一范围内声明了两个var节点
。也就是说,我认为这两个变量都不会被忽略我想它只会抛出“找不到节点”错误。我的意思是targetParentNode.I在执行存储过程时是否看到任何错误消息?如果是,错误消息是什么?您可以在此处找到执行查询的工作示例存储过程:您好,很抱歉回复太晚。我最近很忙。我发现所有这些核心函数都与lead-to-une异步预期的行为。因此,我认为我的存储过程将在这些核心函数完成之前全部运行并返回。嗨,那一定是node.Id。我在做一些测试时复制粘贴的错误。但这不是问题。我自己解决了。我在上一个中添加了注释。