从 DocumentDB 存储过程触发触发器
Fire trigger from DocumentDB stored procedure
我们有一个根据 bulkImport sproc in the DocumentDB sample code. This sproc takes an array of documents, does some stuff, and eventually calls createDocument, which the documentation 所说的异步建模的存储过程。
现在我们已经为 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);
}"
}
我们将其附加到 options
对象,我们将在存储过程中传递给 createDocument
。
var options = {
disableAutomaticIdGeneration: false,
preTriggerInclude: 'triggerNameRedacted'
};
我们希望看到触发器被调用。但是,触发器没有被触发。我们已经尝试了各种修改以尝试看到触发器被触发,但它仍然没有:将批量存储过程和触发器削减到绝对最小值,将 triggerOperation 更改为 "All".
在服务器端包装器的 source 以及上面链接的 Collection 文档中,服务器端代码似乎没有查看任何 *Trigger*
字段选项对象,例如preTriggerInclude
和我们一样。
是否可以通过在存储过程中调用 createDocument
来执行预创建触发器,或者对 的限制是否适用于任何服务器端代码?
无法从服务器端 SDK 调用触发器(例如,从另一个触发器或存储过程中)。
我们有一个根据 bulkImport sproc in the DocumentDB sample code. This sproc takes an array of documents, does some stuff, and eventually calls createDocument, which the documentation 所说的异步建模的存储过程。
现在我们已经为 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);
}"
}
我们将其附加到 options
对象,我们将在存储过程中传递给 createDocument
。
var options = {
disableAutomaticIdGeneration: false,
preTriggerInclude: 'triggerNameRedacted'
};
我们希望看到触发器被调用。但是,触发器没有被触发。我们已经尝试了各种修改以尝试看到触发器被触发,但它仍然没有:将批量存储过程和触发器削减到绝对最小值,将 triggerOperation 更改为 "All".
在服务器端包装器的 source 以及上面链接的 Collection 文档中,服务器端代码似乎没有查看任何 *Trigger*
字段选项对象,例如preTriggerInclude
和我们一样。
是否可以通过在存储过程中调用 createDocument
来执行预创建触发器,或者对
无法从服务器端 SDK 调用触发器(例如,从另一个触发器或存储过程中)。