Figer's Technology Consulting | May 2015

Microsoft Azure mobile services Node.js - Insert record into another table with-in an insert/update call

From Azure portal go into the Insert or update script and add this


function update(item, user, request) {
    request.execute({ success: insertAuditEntry });

    function insertAuditEntry() {
        var auditTable = tables.getTable('audit');
        var audit = {
            record: 'checkins',
            recordId: item.id,
            timestamp: new Date(),
            values: 'Add value here'
        };
        auditTable.insert(audit, {
            success: function() {
                // Write to the response now that all data operations are complete
                request.respond();
            }
        });
    }
}