小编Pet*_*ter的帖子

Azure Cosmos/Document DB触发器

我试图在一个集合上设置一个触发器,它似乎没有绊倒.触发器是使用Azure门户准备的.我正在尝试特定的逻辑 - 但最后只是在Azure站点上放置了一个示例.触发器逻辑如下:

var context = getContext();
var request = context.getRequest();

// document to be created in the current operation
var documentToCreate = request.getBody();

// validate properties
if (!("timestamp" in documentToCreate)) 
{
  var ts = new Date();
  documentToCreate["my timestamp"] = ts.getTime();
}

// update the document that will be created
request.setBody(documentToCreate);
Run Code Online (Sandbox Code Playgroud)

触发器无效.似乎没有出现错误,我不确定发生了什么.

注意:触发器是预先设置的触发器.对于我列出的触发器逻辑,我没有使用"my timestamp"属性创建文档.我还测试了相同概念中的其他场景,我想在创建的文档中添加属性.

azure azure-cosmosdb

1
推荐指数
1
解决办法
2290
查看次数

标签 统计

azure ×1

azure-cosmosdb ×1