Fire trigger from DocumentDB stored procedure

We have a stored procedure that is modeled after bulkImport sproc in the DocumentDB sample code. This sproc takes an array of documents, does some things, and ultimately calls createDocument, which the documentation speaks asynchronously.

Now we have created a preliminary trigger for Create, which checks some fields and optionally adds some additional fields to certain request documents.

{
    "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); 
        }"
}

We attached this to the object optionsthat we are going to createDocumentin our sproc.

var options = {
    disableAutomaticIdGeneration: false,
    preTriggerInclude: 'triggerNameRedacted'
};

. . , , - : sproc , triggerOperation "All".

source , Collection, , , - *Trigger* , preTriggerInclude, .

, createDocument ?

+4
1

SDK (, sproc).

+6

All Articles