0
我試圖在一個集合上放置一個觸發器,它似乎不會跳閘。觸發器已準備好Azure門戶。我正在嘗試特定的邏輯 - 但最終只是在Azure站點上放置了一個示例。觸發邏輯如下:Azure Cosmos /文檔數據庫觸發器
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);
觸發不工作。似乎沒有錯誤產生,我不確定發生了什麼。
注意:觸發器是一個預置觸發器。而對於我列出的觸發邏輯,我並沒有使用「我的時間戳」屬性創建文檔。我還測試了其他場景,其中我想向正在創建的文檔添加屬性。
究竟是如何從一次手術中絆倒?它們只能從代碼觸發嗎?他們可以從Azure Portal絆倒嗎? – Peter
對於node.js SDK,您可以在任何操作的請求選項中指定它(例如,說'upsertDocument()'):http://azure.github.io/azure-documentdb-node/global.html#RequestOptions 。我懷疑其他SDK類似。 –
就我所知,正如Larry Maccherone所說,我們需要在操作中明確指定觸發器來激活觸發器。目前,Azure門戶似乎不支持它。我還發現另一個smilar [SO線程](https://stackoverflow.com/questions/32647843/trigger-in-documentdb-not-fired)。 –