预触发器看起来像这样:
function calculate() {
var context = getContext();
var request = context.getRequest();
var documentToCreate = request.getBody();
documentToCreate["OrderNumber"] = 1;
request.setBody(documentToCreate);
}
我使用带有 PreTriggerInclude 的 C# 客户端 api 创建文档:
var doc = new MyDocument
{
Title = "My Document 1",
//OrderNumber - calculated by PreTrigger
};
var result = await client.CreateDocumentAsync(eventCollectionUri, doc,
new RequestOptions { PreTriggerInclude = new List<string> { "CalculateOrderNumber" }});
// how to get OrderNumber here?
是否可以将计算值返回到响应而无需再次查询文档?