来自DocumentDB存储过程的触发器

sho*_*ver 4 triggers stored-procedures azure-cosmosdb

我们有一个存储过程,它是在DocumentDB示例代码中的bulkImport sproc之后建模的.这个sproc需要一系列文档,做一些事情,并最终调用createDocument,文档说这是异步的.

现在我们已经为Create编写了一个预触发器来检查某些字段,并可选择在请求的某些文档中添加一些其他字段.

{
    "id":"triggerNameRedacted",
    "triggerType": "Pre",
    "triggerOperation": "Create",
    "body": "function()
        { 
            var context = getContext(); 
            var request = context.getRequest();
            var documentToCreate = request.getBody();
            documentToCreate.msg = 'got to here';
            request.setBody(documentToCreate); 
        }"
}
Run Code Online (Sandbox Code Playgroud)

我们将它附加到options我们传递给createDocument我们的sproc中的对象上.

var options = {
    disableAutomaticIdGeneration: false,
    preTriggerInclude: 'triggerNameRedacted'
};
Run Code Online (Sandbox Code Playgroud)

我们希望看到触发器被调用.但是,触发器未被触发.我们已经尝试了各种修改来尝试查看触发器被触发,但它仍然没有:将大量的sproc和触发器削减到绝对最小值,将triggerOperation更改为"All".

在服务器端包装器的源代码中,以及上面链接的Collection文档中,似乎服务器端代码不会查看*Trigger*选项对象的任何字段,例如preTriggerInclude在我们的例子中.

是否可以createDocument在存储过程中调用执行预创建触发器,或者从另一个存储过程调用存储过程的限制是否适用于任何服务器端代码?

And*_*Liu 6

无法从服务器端SDK调用触发器(例如,从另一个触发器或sproc内部调用).